From 1bd6e3400b0d792c8e9a2d16da540161f1c45977 Mon Sep 17 00:00:00 2001 From: Janis Date: Wed, 28 Jun 2023 18:48:19 +0200 Subject: [PATCH] [refactor] add setTimeout before reconnect --- src/teamspeak5Handler.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/teamspeak5Handler.ts b/src/teamspeak5Handler.ts index d24a381..e07bf1f 100644 --- a/src/teamspeak5Handler.ts +++ b/src/teamspeak5Handler.ts @@ -30,6 +30,7 @@ export class TS5Connection { } reconnect() { + console.log("Reconnecting...") this.ws.close(); this.ws = new WebSocket(`ws://localhost:${this.remoteAppPort}`); @@ -74,7 +75,9 @@ export class TS5Connection { localStorage.removeItem("apiKey"); } - this.reconnect(); + setTimeout(() => { + this.reconnect(); + }, 2000); }; // Handle messages received from TS5 client