1
0
Fork 0
mirror of https://github.com/m1k1o/neko.git synced 2025-08-13 09:18:31 +02:00

reconnecter: clear timeout on connect.

This commit is contained in:
Miroslav Šedivý 2021-07-17 15:30:56 +02:00
commit b3a8d5f86d

View file

@ -127,6 +127,11 @@ export class Reconnecter extends EventEmitter<ReconnecterEvents> {
}
public close(error?: Error): void {
if (this._timeout) {
window.clearTimeout(this._timeout)
this._timeout = undefined
}
if (!this._open) {
throw new Error('connection is already closed')
}
@ -141,6 +146,11 @@ export class Reconnecter extends EventEmitter<ReconnecterEvents> {
}
public connect(): void {
if (this._timeout) {
window.clearTimeout(this._timeout)
this._timeout = undefined
}
this._conn.connect()
this._timeout = window.setTimeout(this.onDisconnect.bind(this), this._config.timeoutMs)
}