Upon detecting another user leaving the room, clients will immediately delete the user data, which causes most game logic to break due to the missing user object.
// Remove user from room
SOCKET.on('userLeave', (userID) => {
// Clear user data
console.log(getName(userID), "disconnected");
delete USERS[userID];
updatePlayerList();
});
This crashes the client-side JS, and has the potential to crash the server too. Code-proofing will also need to be implemented to ensure this doesn't happen.
I recommend not deleting USERS[userID], but instead tagging it as a disconnected user. This would also help with issue #2.
Upon detecting another user leaving the room, clients will immediately delete the user data, which causes most game logic to break due to the missing user object.
This crashes the client-side JS, and has the potential to crash the server too. Code-proofing will also need to be implemented to ensure this doesn't happen.
I recommend not deleting
USERS[userID], but instead tagging it as a disconnected user. This would also help with issue #2.