diff --git a/server/server.js b/server/server.js index b88dedc..b79d0a3 100644 --- a/server/server.js +++ b/server/server.js @@ -161,18 +161,7 @@ wss.on('connection', (socket, req) => { //handle disconnecting socket.on('close', () => { - for (var i = players.length - 1; i >= 0; i--) { - broadcast(JSON.stringify({ - type: "removePlayer", - data: { - id: socket.id - } - })); - if (players[i].id == socket.id) { - players.splice(i, 1); - } - } - connections.delete(socket); + deletePlayer(socket); }); });