Add WebSocket option for Stream (#21)
This commit is contained in:
parent
893fa691a7
commit
d311f74349
|
@ -96,8 +96,10 @@ export default class Stream extends EventEmitter<StreamEvents> {
|
||||||
private nonSharedConnections: NonSharedConnection[] = [];
|
private nonSharedConnections: NonSharedConnection[] = [];
|
||||||
|
|
||||||
constructor(origin: string, user: { token: string; } | null, options?: {
|
constructor(origin: string, user: { token: string; } | null, options?: {
|
||||||
|
WebSocket?: any;
|
||||||
}) {
|
}) {
|
||||||
super();
|
super();
|
||||||
|
options = options || { };
|
||||||
|
|
||||||
const query = urlQuery({
|
const query = urlQuery({
|
||||||
i: user?.token,
|
i: user?.token,
|
||||||
|
@ -107,7 +109,8 @@ export default class Stream extends EventEmitter<StreamEvents> {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stream = new ReconnectingWebsocket(`${origin.replace('http://', 'ws://').replace('https://', 'wss://')}/streaming?${query}`, '', {
|
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('open', this.onOpen);
|
||||||
this.stream.addEventListener('close', this.onClose);
|
this.stream.addEventListener('close', this.onClose);
|
||||||
|
|
Loading…
Reference in New Issue