From b4fbd6cb20ccc11ef5acfd1c2cfde1ba3bf1b085 Mon Sep 17 00:00:00 2001 From: elijahr2411 Date: Wed, 15 Feb 2023 15:23:32 -0500 Subject: [PATCH] fix username bug for real this time --- src/index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index c7c7981..fda7f0b 100644 --- a/src/index.js +++ b/src/index.js @@ -69,8 +69,10 @@ class CollabVMClient { #url; #captcha = false; captchaToken; - constructor(url) { + isMainSocket; + constructor(url, isMainSocket) { this.#url = url; + this.isMainSocket = isMainSocket; } connect(hcaptchatoken) { this.captchaToken = hcaptchatoken; @@ -170,7 +172,7 @@ class CollabVMClient { this.eventemitter.emit('captcha', false); } case "chat": - if (!connected) return; + if (!connected || !this.isMainSocket) return; for (var i = 1; i < msgArr.length; i += 2) { chatMessage(msgArr[i], msgArr[i+1]) } @@ -217,7 +219,7 @@ class CollabVMClient { alert("That username has been blacklisted."); break; } - if (!connected) return; + if (!connected || !this.isMainSocket) return; var u = users.find(u => u.username === window.username); if (u) { u.username = msgArr[3]; @@ -234,14 +236,14 @@ class CollabVMClient { user.element.children[0].innerHTML = msgArr[3]; break; case "adduser": - if (!connected) return; + if (!connected || !this.isMainSocket) return; for (var i = 2; i < msgArr.length; i += 2) { this.addUser(msgArr[i], msgArr[i+1]); } onlineusercount.innerText = users.length; break; case "remuser": - if (!connected) return; + if (!connected || !this.isMainSocket) return; for (var i = 2; i < msgArr.length; i++) { var user = users.find(u => u.username == msgArr[i]); users.splice(users.indexOf(user), 1); @@ -599,7 +601,7 @@ class CollabVMClient { } function multicollab(url) { return new Promise(async (res, rej) => { - var vm = new CollabVMClient(url); + var vm = new CollabVMClient(url, false); await vm.connect(); var list = await vm.list(); vm.disconnect(); @@ -715,7 +717,7 @@ async function openVM(url, node) { token = await doCaptcha(vm.captcha); } window.location.href = "#" + node; - vm = new CollabVMClient(url); + vm = new CollabVMClient(url, true); await vm.connect(token); await vm.connectToVM(node); vmlist.style.display = "none";