Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Add WebSocket option for Stream #21

Merged
merged 1 commit into from
May 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ export default class Stream extends EventEmitter<StreamEvents> {
private nonSharedConnections: NonSharedConnection[] = [];

constructor(origin: string, user: { token: string; } | null, options?: {
WebSocket?: any;
}) {
super();
options = options || { };

const query = urlQuery({
i: user?.token,
Expand All @@ -107,7 +109,8 @@ export default class Stream extends EventEmitter<StreamEvents> {
});

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);
Expand Down