fix weird error when client repeatedly connectes
This commit is contained in:
parent
ab878b6718
commit
6c6154c072
1 changed files with 18 additions and 14 deletions
|
@ -74,22 +74,26 @@ class GatewayServer extends EventEmitter {
|
|||
ws.alive = true;
|
||||
});
|
||||
ws.on("close", async () => {
|
||||
if (ws.session.user && this.sessionCounters[ws.session.user._id] <= 1) {
|
||||
this.inChannel(ws.channels[0], (client) => {
|
||||
console.log(client.session);
|
||||
client.send(packet("EVENT_CHANNEL_MEMBERS", {
|
||||
[ws.session.user._id]: {
|
||||
_id: ws.session.user._id,
|
||||
username: ws.session.user.username,
|
||||
status: 0,
|
||||
status_text: "Now offline"
|
||||
}
|
||||
}));
|
||||
});
|
||||
try {
|
||||
if (ws.session.user && this.sessionCounters[ws.session.user._id] <= 1) {
|
||||
this.inChannel(ws.channels[0], (client) => {
|
||||
console.log(client.session);
|
||||
client.send(packet("EVENT_CHANNEL_MEMBERS", {
|
||||
[ws.session.user._id]: {
|
||||
_id: ws.session.user._id,
|
||||
username: ws.session.user.username,
|
||||
status: 0,
|
||||
status_text: "Now offline"
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
this.sessionCounters[ws.session.user._id]--;
|
||||
} catch(e) {
|
||||
console.error("Partially failed to close socket connection", e);
|
||||
}
|
||||
this.sessionCounters[ws.session.user._id]--;
|
||||
|
||||
if (ws.rtc) await ws.rtc.connection.close();
|
||||
if (ws.rtc && ws.rtc.connection) await ws.rtc.connection.close();
|
||||
});
|
||||
ws.on("message", async (data) => {
|
||||
try {
|
||||
|
|
Reference in a new issue