mirror of
https://github.com/m1k1o/neko.git
synced 2025-06-07 21:32:44 +02:00
reconnecter: clear timeout on connect.
This commit is contained in:
parent
0974beaf4a
commit
b3a8d5f86d
1 changed files with 10 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue