-
Notifications
You must be signed in to change notification settings - Fork 0
Matching
Guilherme Souza edited this page Oct 19, 2013
·
1 revision
Just send the MSG_MATCH with this data:
- bool data.want3: whether the player accepts playing against 2 players
- bool data.want4: whether the player accepts playing against 3 players
- string data.name: the player name (does not need to be unique)
- string data.id: a unique id to identify the user during the whole game. Can be easily obtained with
[[NSUUID UUID] UUIDString]
Now you just need to wait, but be aware of disconnection!
After sending MSG_MATCH (and before receiving MSG_MATCH_DONE), the server can send you MSG_MATCH_PROGRESS with this data:
- int data.waitingFor3: the number of players currently waiting for a match with 3 players
- int data.waitingFor4: the number of players currently waiting for a match with 4 players
Therefore, the device can show the user a visual progress feedback.
When the server manages to find a match for you, it will send a MSG_MATCH_DONE with this data:
- string data[].name: the name of the n-th player
- string data[].id: the id of the n-th player
The players will be returned in a randomized order. If you're the first one, you should then start the game.
From this point forward, all messages will be simply broadcasted to all players in the same room.