fix errors when unauthenticated gateway connection disconnected
This commit is contained in:
parent
a429348c7d
commit
e53c99d749
1 changed files with 3 additions and 5 deletions
|
@ -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();
|
||||
|
|
Reference in a new issue