Disconnect/Timeout handling and Input Validation #82
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 methodon_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
This was solved in #90