1. Does the API provide anything to check if peering is all connected?
As indicated in Connecting Players , you can track the connection status of participants using RoomStatusUpdateListener . As noted:
To receive notifications when all players are connected, your game can use the RoomUpdateListener.onRoomConnected() . You can also use RoomStatusUpdateListener callbacks in your game to monitor the connection status of participants. Based on the participant’s connection status, your game can decide whether to start or cancel the game session.
2 - Can I connect the player to the room?
Real-time multiplayer - Gameplay claims that:
After the required number of participants for the room has been connected, the room is considered “filled”, and the game process can begin. After participants join the room, your game may allow them to leave the room (actually throwing them out of the game). However, no new players can join the room after it is “full” (not even to fill the space that the participant vacated).
In addition to this, referring to best practice for real-time multiplayer games :
If you don’t leave the room properly, Google Play Game Services will continue to send notifications of events and invitations to the customer. You must leave the active room when one of the following scenarios occurs:
- The gameplay is over (for example, the player won the match).
- When your game goes into the background.
- On Android, leave the room when:
- The player cancels the game in the wait user interface.
- The response code returned in the
onActivityResult() GamesActivityResultCodes.RESULT_LEFT_ROOM is GamesActivityResultCodes.RESULT_LEFT_ROOM . - The
onStop() operation is onStop() . This may indicate that your Activity is being destroyed. In this case, leave the room and call disconnect() .
Hope these links cover all your concerns. Happy coding! :)
source share