mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
reconnecter: clear timeout on connect.
This commit is contained in:
parent
0974beaf4a
commit
b3a8d5f86d
@ -127,6 +127,11 @@ export class Reconnecter extends EventEmitter<ReconnecterEvents> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public close(error?: Error): void {
|
public close(error?: Error): void {
|
||||||
|
if (this._timeout) {
|
||||||
|
window.clearTimeout(this._timeout)
|
||||||
|
this._timeout = undefined
|
||||||
|
}
|
||||||
|
|
||||||
if (!this._open) {
|
if (!this._open) {
|
||||||
throw new Error('connection is already closed')
|
throw new Error('connection is already closed')
|
||||||
}
|
}
|
||||||
@ -141,6 +146,11 @@ export class Reconnecter extends EventEmitter<ReconnecterEvents> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public connect(): void {
|
public connect(): void {
|
||||||
|
if (this._timeout) {
|
||||||
|
window.clearTimeout(this._timeout)
|
||||||
|
this._timeout = undefined
|
||||||
|
}
|
||||||
|
|
||||||
this._conn.connect()
|
this._conn.connect()
|
||||||
this._timeout = window.setTimeout(this.onDisconnect.bind(this), this._config.timeoutMs)
|
this._timeout = window.setTimeout(this.onDisconnect.bind(this), this._config.timeoutMs)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user