1 - Does the API provide anything to check if the peer is still connected?
As stated in Connecting players, you can monitor the connection status of the participants with the use of RoomStatusUpdateListener
callbacks. As stated:
To be notified when all players are connected, your game can use the RoomUpdateListener.onRoomConnected()
callback. Your game can also use the RoomStatusUpdateListener
callbacks to monitor the connection status of the participants. Based on the participant connection status, your game can decide whether to start or cancel the gaming session.
2 - Is there any way to let the player reconnect to the room?
Real-time Multiplayer - Gameplay states that:
Once the required number of participants for a room have been connected, the room is considered to be 'filled' and gameplay can begin. After participants join a room, your game can allow them to leave the room (effectively dropping them out of the game). However, no new players can join a room after it is 'filled' (not even to fill a spot that a participant has vacated).
In addition to that, referring to best practice for Real-time multiplayer:
If you don't leave the room appropriately, Google Play games services will continue to send event and invitation notifications to the client. You should leave the active room whenever one of these scenarios occurs:
- Gameplay is over (for example, a player has won the match).
- When your game goes into the background.
- On Android, leave the room when:
- The player cancels the game in the waiting room UI.
- The response code returned in the
onActivityResult()
callback is
GamesActivityResultCodes.RESULT_LEFT_ROOM
.
- The Activity
onStop()
is called. This might indicate that your
Activity is being destroyed. In this case, leave the room and call
disconnect()
.
Hope those links covers up all your concerns. Happy coding! :)