Search code examples
androidgoogle-play-servicesandroid-notificationsgoogle-play-games

How should I Implement TBMP Rematch?


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?


Solution

  • 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...