Reputation: 1167
I am using RealTime Multiplayer to create an Android game from here:
https://developers.google.com/games/services/android/realtimeMultiplayer
If two players are connected to a room, and the Internet Connection of one of them is interrupting, i want the other player to get notified.
Currently i don't see any listener that is called when a connection with other player has been lost.
Is there any way to manage this?
Upvotes: 1
Views: 262
Reputation: 191
It is a workaround but you an try,
You can repeatedly send massages from both the players to ensure that the players are connected to network say every 1000 milliseconds,
If you didn't get a message for say 2000 milliseconds then there might be an error at the other players end
Upvotes: 2
Reputation: 931
Create a listener and check network changes
// Indicates the state of Wi-Fi P2P connectivity has changed.
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
Upvotes: 0
Reputation: 581
I have used RealTimeMultiplayer.ReliableMessageSentCallback
interface implemented at the activity and have used workaround this in the following way
@Override
public void onRealTimeMessageSent(int statusCode, int tokenId, String recipientParticipantId) {
switch (statusCode) {
case GamesStatusCodes.STATUS_OK:
messageSent = true;
break;
case GamesStatusCodes.STATUS_REAL_TIME_ROOM_NOT_JOINED:
break;
case GamesStatusCodes.STATUS_REAL_TIME_MESSAGE_SEND_FAILED:
messageSent = false;
break;
}
}
but still the GamesStatusCodes.STATUS_REAL_TIME_MESSAGE_SEND_FAILED
gets called after say 15 to 30 seconds later
Upvotes: 3