remove sockets when closed

This commit is contained in:
Zutatensuppe 2020-12-24 15:04:58 +01:00
parent 11e5c08154
commit 1c9fc428b9
2 changed files with 9 additions and 10 deletions

View file

@ -121,11 +121,13 @@ const notify = (data, sockets) => {
}
wss.on('close', async ({socket}) => {
const proto = socket.protocol.split('|')
const clientId = proto[0]
const gameId = proto[1]
if (Game.exists(gameId)) {
try {
const proto = socket.protocol.split('|')
const clientId = proto[0]
const gameId = proto[1]
GameSockets.removeSocket(gameId, socket)
} catch (e) {
console.error(e)
}
})