From dd6a0513e4ddf8577296502c073c4b691f4b7369 Mon Sep 17 00:00:00 2001 From: marihachi Date: Sun, 23 May 2021 16:49:09 +0900 Subject: [PATCH] Add WebSocket option for Stream --- src/streaming.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/streaming.ts b/src/streaming.ts index 66a800d..b609d83 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);