add disconnect method for client

This commit is contained in:
nvms 2024-09-03 09:22:19 -04:00
parent 24b856b78f
commit b55d854b8a

View File

@ -97,6 +97,16 @@ export class KeepAliveClient extends EventTarget {
}, this.options.pingTimeout + this.options.maxLatency); }, this.options.pingTimeout + this.options.maxLatency);
} }
disconnect() {
this.options.shouldReconnect = false;
if (this.socket) {
this.socket.close();
}
clearTimeout(this.pingTimeout);
}
async reconnect() { async reconnect() {
if (this.isReconnecting) { if (this.isReconnecting) {
return; return;