From e53c99d7499d4cc48ee0a0f1f935e9e7a78b243a Mon Sep 17 00:00:00 2001 From: hippoz Date: Sun, 5 Sep 2021 18:59:38 +0300 Subject: [PATCH] fix errors when unauthenticated gateway connection disconnected --- brainlet/api/v2/gateway/index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/brainlet/api/v2/gateway/index.js b/brainlet/api/v2/gateway/index.js index 8742e36..510733a 100644 --- a/brainlet/api/v2/gateway/index.js +++ b/brainlet/api/v2/gateway/index.js @@ -76,8 +76,8 @@ class GatewayServer extends EventEmitter { ws.alive = true; }); ws.on("close", async () => { - try { - if (ws.session.user && this.sessionCounters[ws.session.user._id] <= 1) { + if (ws.session.user) { + if (this.sessionCounters[ws.session.user._id] <= 1) { this.inChannel(ws.channels[0], (client) => { console.log(client.session); client.send(packet("EVENT_CHANNEL_MEMBERS", { @@ -85,14 +85,12 @@ class GatewayServer extends EventEmitter { _id: ws.session.user._id, username: ws.session.user.username, status: 0, - status_text: "Now offline" + status_text: "" } })); }); } this.sessionCounters[ws.session.user._id]--; - } catch(e) { - console.error("Partially failed to close socket connection", e); } if (ws.rtc && ws.rtc.connection) await ws.rtc.connection.close();