From d311f74349686218d6650495df8b89a211209f98 Mon Sep 17 00:00:00 2001 From: marihachi Date: Sun, 23 May 2021 16:53:11 +0900 Subject: [PATCH] Add WebSocket option for Stream (#21) --- src/streaming.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/streaming.ts b/src/streaming.ts index 66a800d4c..b609d831a 100644 --- a/src/streaming.ts +++ b/src/streaming.ts @@ -96,8 +96,10 @@ export default class Stream extends EventEmitter { private nonSharedConnections: NonSharedConnection[] = []; constructor(origin: string, user: { token: string; } | null, options?: { + WebSocket?: any; }) { super(); + options = options || { }; const query = urlQuery({ i: user?.token, @@ -107,7 +109,8 @@ export default class Stream extends EventEmitter { }); this.stream = new ReconnectingWebsocket(`${origin.replace('http://', 'ws://').replace('https://', 'wss://')}/streaming?${query}`, '', { - minReconnectionDelay: 1 // https://github.com/pladaria/reconnecting-websocket/issues/91 + minReconnectionDelay: 1, // https://github.com/pladaria/reconnecting-websocket/issues/91 + WebSocket: options.WebSocket }); this.stream.addEventListener('open', this.onOpen); this.stream.addEventListener('close', this.onClose);