Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnect/Timeout handling and Input Validation #82

Merged
merged 9 commits into from
Feb 26, 2024

Conversation

Cari1111
Copy link
Collaborator

@Cari1111 Cari1111 commented Feb 25, 2024

Issues

Changes

Disconnect handling

When a player disconnects, all games that he currently participates in, are being forced to end. This means all players are notified that the game ended, and the game loop stops. Additionally the player that disconnected is saved in the game as self.disconnected_player_id.

Game Result

Every game has now scores that are stored as floats in the dictionary self.scores.
With that and the saved disconnected player, the result of the game can be created for every game in the same way. This is now done in IGame. The games are now all correctly written into the database.

Timeout handling

The Server has now a new method on_timeout(player, failure, timeout) which is called, when the connection of a player has a timeout. The player is then disconnected (with that e.g. games are handled).

Input Validation

The actions that are send are now validated by using the abstract method _validate_action(action). If an action is not valid, the player is disconnected.

Errbacks in the protocoll

All errors in the protocol are now handled in the handle_remote_error() method. This method is currently just printing a log message and I'm not sure what else to do, or if these messages are already too much, because the errors mostly occur when a player disconnects, and then they can be ignored.

This was solved in #90

Copy link
Collaborator

@PacoSchatz PacoSchatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. I didn't manage to produce an unhandled error if disconnecting various clients while several games are running.

Maybe you could think about renaming the force_end() or improving the docstring function in interfaces.py as I didn't immediately understand it's purpose. Otherwise its good! :)
Nice thx!

@Cari1111 Cari1111 merged commit 1ebdbe3 into main Feb 26, 2024
4 checks passed
@Cari1111 Cari1111 deleted the carina/disconnect-error-handling branch February 26, 2024 11:56
@Cari1111 Cari1111 self-assigned this Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write disconnected games in the game-database handle client disconnect Input Validation
2 participants