I have a multiplayer poker game where many clients connects to a server. The game is currently in the last round of betting. One client decides not to play the next hand and signals the server that he is sitting out, but the sit out signal arrived after the server dealt the hands to the clients. Thus the client that chose to sit out got a hand when he was not suppose to. How can I solve this? Here is a diagram.
client server
| send(sitout)
| send(hands)
| recv(sitout)
V recv(hand)
Client should either send “Sitout” or “Ready” signal and then server will decide to deal the hand to the client or not.
Solving race conditions is not about moving backwards in time! No entity (in this case the server) can do anything before getting needed information about what is he going to do 🙂