Skip to content

Commit

Permalink
Merge pull request #3 from github/feat-add-configurable-reconnectwindow
Browse files Browse the repository at this point in the history
feat: add configurable reconnectWindow
  • Loading branch information
keithamus authored Oct 22, 2021
2 parents 475c258 + c341b5a commit b345902
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/stable-socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface Socket {
}

export interface SocketDelegate {
reconnectWindow?: number
socketDidOpen(socket: Socket): void
socketDidClose(socket: Socket, code?: number, reason?: string): void
socketDidFinish(socket: Socket): void
Expand Down Expand Up @@ -55,7 +56,7 @@ export class StableSocket implements Socket {
if (fatal) {
this.delegate.socketDidFinish(this)
} else {
setTimeout(() => this.open(), rand(100, 150))
setTimeout(() => this.open(), rand(100, 100 + (this.delegate.reconnectWindow || 50)))
}
}
this.socket.onmessage = (event: MessageEvent) => {
Expand Down

0 comments on commit b345902

Please sign in to comment.