Skip to content

Game breaks if a user disconnects mid-game #7

Description

@gitchly

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingurgentIt's important that this issue is dealt with ASAP

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions