From 393b985f2ac734b9794c47ccf827a630f4ea6c4b Mon Sep 17 00:00:00 2001 From: MDMCK10 <21245760+MDMCK10@users.noreply.github.com> Date: Thu, 18 May 2023 23:33:01 +0200 Subject: [PATCH] Fix everything else --- src/index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/index.js b/src/index.js index f24c4de..06edaeb 100644 --- a/src/index.js +++ b/src/index.js @@ -83,6 +83,7 @@ class CollabVMClient { #captcha = false; captchaToken; isMainSocket; + shouldReconnect = true; constructor(url, isMainSocket) { this.#url = url; this.isMainSocket = isMainSocket; @@ -103,14 +104,16 @@ class CollabVMClient { } #onClose() { cleanup(); - setTimeout(async () => { - try { - await this.connect(); - } catch { - this.#onClose(); - } - this.connectToVM(this.node); - }, 2000); + if(this.shouldReconnect) { + setTimeout(async () => { + try { + connected = await this.connect(this.captchaToken); + } catch { + this.#onClose(); + } + this.connectToVM(this.node); + }, 2000); + } } disconnect() { this.socket.send(guacutils.encode(["disconnect"])); @@ -733,6 +736,7 @@ function returnToVMList() { if(!connected) return; connected = false; vm.disconnect(); + vm.shouldReconnect = false; vmview.style.display = "none"; vmlist.style.display = "block"; }