From b55d854b8a9cd2042103d6f9f8b8c3b15d26613e Mon Sep 17 00:00:00 2001 From: nvms Date: Tue, 3 Sep 2024 09:22:19 -0400 Subject: [PATCH] add disconnect method for client --- packages/keepalive-ws/src/client/client.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/keepalive-ws/src/client/client.ts b/packages/keepalive-ws/src/client/client.ts index 03177e9..b067073 100644 --- a/packages/keepalive-ws/src/client/client.ts +++ b/packages/keepalive-ws/src/client/client.ts @@ -97,6 +97,16 @@ export class KeepAliveClient extends EventTarget { }, this.options.pingTimeout + this.options.maxLatency); } + disconnect() { + this.options.shouldReconnect = false; + + if (this.socket) { + this.socket.close(); + } + + clearTimeout(this.pingTimeout); + } + async reconnect() { if (this.isReconnecting) { return;