Unregister PING timer when destroying client
This commit is contained in:
@@ -46,6 +46,7 @@ export default class Client extends EventTarget {
|
||||
batches = new Map();
|
||||
autoReconnect = true;
|
||||
reconnectTimeoutID = null;
|
||||
pingIntervalID = null;
|
||||
pendingHistory = Promise.resolve(null);
|
||||
cm = irc.CaseMapping.RFC1459;
|
||||
whoisDB = new irc.CaseMapMap(null, irc.CaseMapping.RFC1459);
|
||||
@@ -111,6 +112,8 @@ export default class Client extends EventTarget {
|
||||
clearTimeout(this.reconnectTimeoutID);
|
||||
this.reconnectTimeoutID = null;
|
||||
|
||||
this.setPingInterval(0);
|
||||
|
||||
if (this.ws) {
|
||||
this.ws.close(1000);
|
||||
}
|
||||
@@ -444,6 +447,21 @@ export default class Client extends EventTarget {
|
||||
return this.cm(nick) == this.cm(this.nick);
|
||||
}
|
||||
|
||||
setPingInterval(sec) {
|
||||
clearInterval(this.pingIntervalID);
|
||||
this.pingIntervalID = null;
|
||||
|
||||
if (sec <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pingIntervalID = setInterval(() => {
|
||||
if (this.ws) {
|
||||
this.send({ command: "PING", params: ["gamja"] });
|
||||
}
|
||||
}, sec * 1000);
|
||||
}
|
||||
|
||||
/* Execute a command that expects a response. `done` is called with message
|
||||
* events until it returns a truthy value. */
|
||||
roundtrip(msg, done) {
|
||||
|
||||
Reference in New Issue
Block a user