How should I Implement TBMP Rematch? - android

I'm creating a multiplayer tic tac toe game and it works for the most part, but when it's time to rematch I'm getting less than desirable functionality.
So originally I used the same implementation of Games.TurnBasedMultiplayer.rematch as the TBMPSkeleton sample project. Basically after calling Games.TurnBasedMultiplayer.finish, I check whether or not the match can be rematched by calling match.canRematch() during the subsequent callback. If match.canRematch() returns true, then I call Games.TurnBasedMultiplayer.rematch. Both, when I call finish and when I call rematch, the onTurnBasedMatchReceived callback gets called on the opposing client device and from there I check the match object for the rematchId. If it's not null, then I reset the game.
The problem I'm having is that, after the winning player has requested a rematch and then takes his/her turn, the opposing player receives an invite to the new match, but the onTurnBasedMatchReceived callback doesn't get called. I don't want the losing player to have to leave my game in order to accept or dismiss the invitation.
So is there a way to have my app handle the invitation notification without forcing the player to have to open the system's notification gui? Should I scrap the turn based multiplayer API in favor of it's real-time counterpart?

I realized that I didn't have a listener registered for invitations. After registering one, I was able to achieve my desired functionality. I'm relieved that it's working, but it would have been nice to notice that much sooner...

Related

Turn Based Game player receives its own data without opponent calling takeTurn

I have been implementing my own turn based board game. Whole game is based on PlayGameService's SkeletonTbmp example with some modifications.
My problem is that a player sometimes receives its own data that it sent to the opponent using takeTurn(). I have checked many times that getNextParticipantId() returns the right id. For example my emulator persists a move data and sends it correctly to my actual Android phone and my phone unpersists as implemented in the example. Then some seconds later my emulator receives this same data without actual device persisting it and calling takeTurn(). This also happens sometimes on game start on the first turn, emulator receives the first "dummy" turn data without actual device sending anything yet. It does not happen every single turn, just occasionally.
Could this be something with my Google Play Console settings or does these turns buffer some how and then they are released at some point?
As you have not giving any codes i cannot pinpoint the problem. But just for the explanation, as long as the match is going, match will contain data, whether its your turn or not. To pinpoint the exact place this is happening, put checks at the execution of updatematch() as it must be firing without actual need. (on login, reconnect, initiate, connectionhint etc). Can't be sure about your code but alternate approach to bypass the bug, you can actually put check on turncounter in addition of MATCH_TURN_STATUS_MY_TURN otherwise pass the null turn. Hope it helps as further i cant help without your code.
It seems that i just forgot to always remove the old games from the "check games"-UI, thats why it sends the same data after a while, when i am already attending to a new game with same opponent.

GPGS Turn-Based Multiplayer - Set participant status?

The question might seem quite odd, but I couldn't quite find an answer perusing the API documentation.
What is the purpose of the participant's status?
Is it possible to manually set the status to finished, so that the active games list would show said game for participant to be finished, rather than calling finishMatch()?
The scenario in mind would involve a game with more than two players. Say player A finishes the game, his status should be set to "FINISHED", while player B and C would still play, until either one of them finishes, which would trigger the end of the game.
Usually Participant status could be shown in UI. Have you found any API which allows you to change Participant status directly? I think to change it to FINISHED you need to call finishMatch().

Making Simultaneous App-to-Phone Calls (Android)

We are developing a new app using the sinch voice api to make app-to-phone calls for Android.
We’ve tried the sample project and everything works brilliant except that we can’t make simultaneous calls with the same app. We’ve installed the sample project in 2 different android phones and if that 2 devices try to make a call with sinch at the same time one of them can’t make the call. We’ve tried with different users and even tried to create a production app in the sinch dashboard but nothing worked.
So what can we do to make this work? We have to create an app and generate api keys for every device that we are going to use in order to make simultaneous app-to-phone calls?
Thanks
I can see you already added my answer as a comment to your own question, but I'll add it myself anyway for any other person looking for the same question. I'm also adding information on how to set the maxDuration.
When your application makes a PSTN call, our system reserves a sum on your account to make sure you have enough credit to actually pay for the call. If you don’t specify the maximum duration for a call, we reserve 240 minutes X minute price to the destination. If you don't have enough credit on your account, the call will be denied.
Suggestion 1: Set maxDuration to a level you can handle (see below for info on setting maxDuration from the SDK)
Suggestion 2: Make sure you have enough credit on your account and also that PayPal auto top-up is enabled.
If you're using one of our SDKs you need to set a callback URL that our service can talk to:
Set a callback URL for you application on sinch.com.
When a user tries to make a call, we send you a callback to this URL. This callback is called ICE (Incoming Call Event) and lets you decide if the call should be allowed or not.
You need to answer our callback for the call to go through. The action to send back is called ConnectPSTN and you can read more about it here: https://www.sinch.com/docs/voice/rest/#ConnectPSTNAction Use the maxDuration parameter to decide the maximum length a call is allowed.

In Android multiplayer, which override is called when an invitation is accepted?

I have implemented the multi player feature in my game. when I click the "Invite friends" button, I am redirected the the screen to invite my friends. The invitation goes and by the time my friends respond, if I navigate away from the screen that shows the list of friends, then which override is called when the invitation that I sent is accepted.
I wanted to go to that override and start my game. Else the person who accepted the game starts the game, but i am not able to start my game.
The RoomUpdateListener interface defines the callbacks for client state changes.
You might want to look at the ButtonClicker sample which is a real-time multiplayer game.
The basic flow is:
1. Build the room including the invited players and call Games.RealTimeMultiplayer.create(mGoogleApiClient, rtmConfigBuilder.build());
Once the room is created, [onRoomCreated](https://developers.google.com/android/reference/com/google/android/gms/games/multiplayer/realtime/RoomUpdateListener.html#onRoomCreated(int, com.google.android.gms.games.multiplayer.realtime.Room)) is called, indicating if the room was created successfully. In this method is a good time to show the waiting room UI until all the players are connected. The waiting room is shown by getting the intent and starting it. See [getWaitingRoomIntent](https://developers.google.com/android/reference/com/google/android/gms/games/multiplayer/realtime/RealTimeMultiplayer.html#getWaitingRoomIntent(com.google.android.gms.common.api.GoogleApiClient, com.google.android.gms.games.multiplayer.realtime.Room, int))
Once all the players are connected, the waiting room activity will finish, and onActivityResult will be called. From there you can start your gameplay.
If you don't want to use the waiting room, you can implement the [RoomStatusUpdateListener.onPeersConnected](https://developers.google.com/android/reference/com/google/android/gms/games/multiplayer/realtime/RoomStatusUpdateListener.html#onPeersConnected(com.google.android.gms.games.multiplayer.realtime.Room, java.util.List)) and related methods to determine when to start playing.

Game Services Alert in Notification Bar, but no call to onTurnBasedMatchUpdated()?

When I call takeTurn(), I will get a call to onTurnBasedMatchUpdated() on the same device that called takeTurn(). But I will not get the call to onTurnBasedMatchUpdated() on the other device that is waiting for its turn. Instead, Game Services will alert the device that it is their turn to play in the notification bar. I was hoping that, if the device remained in-game, that the game would continue to catch onTurnBasedMatchUpdated() when the other player calls takeTurn(). So how do I prevent the notification and simply handle the call?
As Mannan pointed out, it is onTurnBasedMatchReceived() that is called when an opponent takes their turn. It is also called when an opponent connects to your match for the first time. While this function is required to be defined for an "OnTurnBasedMatchUpdatedListener" it is not actually called for that listener. You must ALSO implement "OnTurnBasedMatchUpdateReceivedListener". Further, after implementing it, you must then REGISTER it (I do so after signing in) with getGamesClient().registerMatchUpdateListener(this). Seriously though, where is all the documentation for this? Am I missing something?
When a player's turn is arrived, following callback is called,
onTurnBasedMatchReceived(TurnBasedMatch match)
and in this callback, you can get info about the turn and its data from match parameter.
I still dont know why onTurnBasedMatchUpdated() is not called.

Categories

Resources