End a multiplayer game on finishMatch - android

I am developing a turn based multiplayer game in Android using Google Play Game Services.
I have successfully ended the game when the user clicks the Finish Button:
Games.TurnBasedMultiplayer.finishMatch(mGoogleApiClient, mMatch.getMatchId(), mMatch.getData(), creatorResult, opponentResult)
.setResultCallback(new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
#Override
public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
processResult(result);
}
});
The current player's game gets updated in the "Completed Games" section.
However the opponent's game is listed as "My Turn"
From the Developing a Turn Based Multiplayer Game in Android page:
"Play Game services sends a notification to all other match participants to inform them that the match is over. These participants see this match under Your Turn category in their respective match list UIs. At this point, your game can call finishMatch() for these participants to save their final game data. Invoking this method also moves the match to the Completed Matches category in the participant’s match list UI."
How do I call finishMatch for the other players?
--Is it through the mGoogleApiClient
--Or is there a way to make the oppononent's match status = MATCH_STATUS_COMPLETE
Can someone please help?

You should make the following call on each of the other players devices:
Games.TurnBasedMultiplayer.finishMatch( mGoogleApiClient, mMatch.getMatchId());
This will cause the following status changes on each players device:
Match status will change from MATCH_STATUS_ACTIVE to
MATCH_STATUS_COMPLETE
Match turn Status will change from
MATCH_TURN_STATUS_MY_TURN to MATCH_TURN_STATUS_COMPLETE.
The participant status of the player will change from STATUS_JOINED to
STATUS_FINISHED.
Note that a players participant status may remain STATUS_JOINED on the other players devices (at least thats what I see in my implementation).

Related

Play single track spotify sdk

I am using the Spotify android SDK, and I am trying to get a single song to play, and I would like to potentially play a song after the current one is completed. The issue is that after the song completes Spotify plays a random song afterwards. Is it possible to play the song and not have anything else automatically play after it?
I am simply calling the app remotes player API play function,
mSpotifyAppRemote?.getPlayerApi()?.play(uri)
#Mikee you are doing nothing wrong, Spotify messes around with track replay if you are only using the Free version, if you use Premium it will work correctly. Funny enough if you try playing by an alblum or artist that works with the Free version.
I'm not an expert but from their documentation it looks like you could watch the PlayerState. I'm also not sure when a PlayerState event would trigger but if it's coming back relatively often you could check the track value and see if it's gone to null, or another value and work using that.
Here's a Java example from their website:
// Subscribe to PlayerState
mSpotifyAppRemote.getPlayerApi()
.subscribeToPlayerState()
.setEventCallback(new Subscription.EventCallback<PlayerState>() {
public void onEvent(PlayerState playerState) {
// See what values are in playerState, might be able to determine
// if it's now randomly playing?
final Track track = playerState.track;
if (track != null) {
Log.d("MainActivity", track.name + " by " + track.artist.name);
// If the track is now different, your song has finished, stop it?
}
}
});
I've put a few extra comments in the code above that might yield some results!

Unity Google Play Games IsConnectedToRoom Check

I'm having trouble to check if a participant is still connected to a room.
I wrote this:
bool status=GooglePlayGames.Native.PInvoke.MultiplayerParticipant.AutomatchingSentinel().IsConnectedToRoom();
if (status = true)
{
this.gameObject.GetComponent<Text> ().text = "participant is connected";
}
if (status = false)
{
this.gameObject.GetComponent<Text> ().text = "participant left";
}`
When players are connected, "participant is connected" is displayed.
But when a player press the home button, and go back to the screen, the participant had OnPeersDisconnected called and leave the room. But for the actual player, "participant is connected" is still displayed.
How can i know when the IsConnectedToRoom() is false?
This may still depend on how implementation is going to be. According to the document:
Make sure to construct your game logic carefully to take each participant's status and connectedness into account. For example, to determine if all racers have crossed the finish line, your game should only consider the participants who are connected; some may have left the room or never have accepted the invitation.
Detecting when a player is disconnected
Your player might be disconnected from the room due to network connectivity or server issues. To be notified when a player is disconnected from the room, implement the OnConnectedSetChanged method.
virtual void OnConnectedSetChanged(RealTimeRoom const &room) {
// Check the room's participants to see who connected/disconnected.
}
Hope this helps.

I am trying to make an application that will make phone calls one after another from the list of number

I am developing an application for my friend who is in sales, this application will make phone calls one after another, as soon as one phone call gets disconnected, it will automatically make call to another number from the list. This list can be read from and xml data source or json or mongodb or even from excel sheet.
This could be an ios app that reads data from an end point and stores them and can initiate the call at any point and it wont stop until all the calls are made.
Next call will be made only after the first call has been finished.
I am thinking about using node based web app using google voice to trigger the chain.
I've no experience with ios / android apis but Im willing to work on that if it's a viable thing on that platform.
Note: what we're trying to avoid is whole process of
looking up the phone number.
touch hangup and then click for another phone number.
It should self trigger the next call as soon as current call gets disconnected.
Also we're trying to avoid any paid services like twillo.
Thanks in advance :)
for IOS, you could use CTCallCenter
self.callCenter = [[CTCallCenter alloc] init];
self.callCenter.callEventHandler = ^(CTCall *call){
if ([call.callState isEqualToString: CTCallStateConnected])
{
//NSLog(#"call stopped");
}
else if ([call.callState isEqualToString: CTCallStateDialing])
{
}
else if ([call.callState isEqualToString: CTCallStateDisconnected])
{
//NSLog(#"call played");
}
else if ([call.callState isEqualToString: CTCallStateIncoming])
{
}
};
Download phone list, loop inside phone list, make a call, listening for CTCallCenter and appdelegate's Event, detect user have finish last call, our app active again, then make the next call.
Or you can try in Demo here !

How to allow user to use loadConnectedPlayers

I want to get all connected players to game. I can get players that are in google+ circles but I want the player to get all users. I can't find what permission do I need to do this.
I am using this code to get players, but it always returns 0.
PendingResult<LoadPlayersResult> players = Games.Players.loadConnectedPlayers(mGoogleApiClient, false);
players.setResultCallback(new ResultCallback<Players.LoadPlayersResult>()
{
#Override
public void onResult(LoadPlayersResult result)
{
PlayerBuffer buf = result.getPlayers();
Toast.makeText(getApplicationContext(), "players"+buf.getCount(), Toast.LENGTH_SHORT).show();
}
});
this had been pre-announced and then announced a while ago already and method .loadConnectedPlayers() had been deprecated... which merely boils down to, that Google+ had been separated from Play Games and the functionality you are looking for is not available anymore.
in order to get a list of connected players, you would have to use your own API now. Just seen the question is old and had been posted before the announce - nevertheless this appears to be the current status.

Disable Rematch in Google Play Games

I use Google Play Games Services and everythink working fine (leaderboards, random opponent etc etc)
But when a player call finishMatch(), the status of match.canRematch() is always "true", beyond the result.
If the player has won the battle may not be able to ask for a rematch!
I use this code to send the result:
Games.TurnBasedMultiplayer.finishMatch(mGoogleApiClient,
mMatch.getMatchId(), mMatch.getData(), myscore, creatorscore).setResultCallback(
new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
#Override
public void onResult(
TurnBasedMultiplayer.UpdateMatchResult result) {
processResult(result);
}
});
I would like to disable the possibility of revenge. How can I do?
Ok. This IS an answer.
It is not possible from the API to disallow rematch.
However, I just discovered a workaround that achieves the same effect.
detect whether a match is a rematch by calling getMatchNumber() and getPreviousMatchData(). Cancel/Dismiss the match if the former isn't 1 or the latter isn't null. It ensures a rematch user input will have the same effect as a dismissal.
when a match is completed completely (cancelled, expired, or MATCH_STATUS_COMPLETE && MATCH_TURN_STATUS_COMPLETE), dismiss it right away. It minimizes the chance that the user will even see the "Match complete, rematch" UI. This check can also be checked periodically for matches in the inbox.

Categories

Resources