Reputation: 925
My problem is that i don't understand how to tell when player disconnected.
So my game includes 2 players, the game itself works, when one player leaves the game like intended or close the application in manager, everything is fine, but when one player let's say loses internet connection nothing happens. I tried that by disabling internet connection on one player's device.
When one player leaves the game RoomStatusUpdateCallback
calls methods in this sequence : 1.onDisconnectedFromRoom
2.onPeerLeft
3.onPeersDisconnected
, but when one playes loses internet connection nothing is called. I'd like to know when one players loses connection.
I believe there is something like ConnectivityManager
so i can probably use this at one player's device, but how do the second player know that the first one lost connection when RoomStatusUpdateCallback
doens't say anything?
Upvotes: 0
Views: 62
Reputation: 880
Whenever a player disconnects from a network connectivity or servers issue, the connection status of the participant doesn't change until you call to leave the room. You can just monitor the connection status of the participants inside the room using RoomStatusUpdateListener
methods as follows when other player is disconnected:
1.onDisconnectedFromRoom
2.onPeerLeft
3.onPeersDisconnected
See full documentation on handling room creation errors.
I think you can try to implement a custom watcher timers on the clients that will repeatedly ping other peers to see if they're still connected.
Upvotes: 1