Hi,
I have a question regarding the matchmaking for the turn-based multiplayer of App42. If I understand the word junkie example [1] correctly, then matchmaking with random players works something like this:
1. retrieve list of files from random_stack collection
2. choose random file
3. random file contains second player id for this game
4. remove random file from collection
5. start playing with player
Isn't it very likely that a race condition happens between choosing a random player and removing the random player from the collection? A third player could randomly get the same file in step 2 and start a game with this randomly drawn player. However, the randomly drawn player will already be busy with the player, who asked him first.
Does the server throw a message that the file already was deleted by another player. If I can catch this, I could try to select another random player. Is the remove file operation implemented in a way that if two players try to delete the same file at the same time, only one player actually is successful and the other one is notified that he failed so that he can try another random file?
Best,
Markus
[1]
http://api.shephertz.com/app42-dev/ebook-turn-based-games.php