I'm using a turn based multiplayer game.
Player 1 starts the game, Player 2 ends. But I always get errors.
This is the code for Player 2:
String playerId = Games.Players.getCurrentPlayerId(getApiClient());
String myOponentId = mMatch.getParticipantId(playerId);
opponentResult = new ParticipantResult(myOponentId,
ParticipantResult.MATCH_RESULT_WIN, 1);
creatorResult = new ParticipantResult(playerId,
ParticipantResult.MATCH_RESULT_LOSS, 2);
Games.TurnBasedMultiplayer.finishMatch(getApiClient(), mMatch.getMatchId(),mMatch.getData(), creatorResult,opponentResult )
.setResultCallback(new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
#Override
public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
processResult(result);
}
});
Log:
E/Volley﹕ [2816] a.a: Unexpected response code 400 for https://www.googleapis.com/games/v1/turnbasedmatches/ChEKCQixqozpwBoQAhACGAAgARDEt9LOpreWivoB/finish?language=en_GB
E/cc﹕ Failed to finish match: null
W/cc﹕ {"code":400,"errors":[{"message":"Invalid participantId with value 108607338309210360902.","domain":"global","reason":"invalid"}]}
Using finishMatch like in the example SkeletonActivity.java is working, but does not produce a winner:
Games.TurnBasedMultiplayer.finishMatch(getApiClient(), mMatch.getMatchId()
ok i messed up the nubers. have to set participant ids whichs is something like p_1 and not a number
myOponentParticipantId
Related
Right now my application is in Internal testing in the google play console.
I have 3 months,6 months, and 1-year subscriptions in the application.
I already bought 6 months subscription and now I am trying to upgrade my subscription to 12 months.
I have also attached the bit of the code, where I am checking if the user has any existing subscription or not by checking the presence of receipt.
if there is no existing subscription then I am directly buying the subscription
using "BuyProductID(_1YearSubscription);",
else
I am trying to upgrade it to the new subscription using
" SubscriptionManager.UpdateSubscriptionInGooglePlayStore(oldProduct, m_StoreController.products.WithID(_1YearSubscription), (string msg1, string msg2) =>
{
IgoogleplayStoreExtention.UpdateSubscription(oldProduct, m_StoreController.products.WithID(_1YearSubscription), GooglePlayStoreProrationMode.ImmediateWithoutProration);
});"
but I am getting an error that says
"2021-06-17 10:34:09.811 26172 26232 Info Unity Error: the product that will be updated does not have a valid receipt: System.NullReferenceException: Object reference not set to an instance of an object."(this is from android logcat).
what exactly is the issue and how can u fix it??
unity version is 2019.4.18
Thanx for the answer in advance.
public void Buy1YearSubscription()
{
print("trying to buy 12 months of subscription");
bool alreadyHaveSomeSubscription = false;
Product oldProduct = m_StoreController.products.WithID(_1YearSubscription);
foreach (Product p in m_StoreController.products.all)
{
GooglePurchaseData data = new GooglePurchaseData(p.receipt);
if (p.hasReceipt)
{
alreadyHaveSomeSubscription = true;
oldProduct = m_StoreController.products.WithID(data.json.productId);
GooglePurchaseData data2 = new GooglePurchaseData(oldProduct.receipt);
print("Has the reciept of----->" + data2.json.productId);
break;
}
}
if (!alreadyHaveSomeSubscription)
{
print("no previous subscription");
BuyProductID(_1YearSubscription);
}
else
{
print("upgrading to 1year");
SubscriptionManager.UpdateSubscriptionInGooglePlayStore(oldProduct, m_StoreController.products.WithID(_1YearSubscription), (string msg1, string msg2) =>
{
IgoogleplayStoreExtention.UpdateSubscription(oldProduct, m_StoreController.products.WithID(_1YearSubscription), GooglePlayStoreProrationMode.ImmediateWithoutProration);
});
}
}
I'm working with In-App update from here:
https://developer.android.com/guide/app-bundle/in-app-updates
I have successfully implemented it in my app. My app is already in playstore:
https://play.google.com/store/apps/details?id=com.tekitsolution.remindly
for Testing this implementation, I decreased version in my project and I implemented in Splash Activity.
So, I got the update screen, I click on update and it started downloading. After completing the download, it is again coming same page to download and installErrorCode is getting -100 which means An internal error happened in the Play Store. (Is there a way to understand what install error codes actually mean?)
Flow from update screen:
I printed logs for `state.installStatus()`
PENDING = 1;
DOWNLOADING = 2;
DOWNLOADED = 11;
INSTALLING = 3;
then instead of this (INSTALLED = 4), I'm getting FAILED = 5 with state.installErrorCode -100
Code:
private InstallStateUpdatedListener installStateUpdatedListener = new
InstallStateUpdatedListener() {
#Override
public void onStateUpdate(InstallState state) {
showLog("In-App: " + state.installStatus());
showLog("installErrorCode " + state.installErrorCode());
if (state.installStatus() == InstallStatus.DOWNLOADED) {
popupSnackbarForCompleteUpdate();
} else if (state.installStatus() == InstallStatus.INSTALLED) {
if (mAppUpdateManager != null) {
showLog("In-App: unregisterListener");
mAppUpdateManager.unregisterListener(installStateUpdatedListener);}
}
}
};
Note: I tried with different devices also.
I have a receiver app (V2) that works fine when you show the first video, but when you go to show a second video I get this:
[cast.receiver.platform.WebSocket] PlatformChannel Already open
I am unloading and loading the player each time. I can't see any way to explicitly ask the PlatformChannel to close. Here's the relevant code from the function that starts play:
this.receiverManager.start()
this.host = new cast.player.api.Host({'mediaElement':this.refs.video, 'url':source})
this.host.onError = function(errorCode) {
console.log("Fatal Error - " + errorCode)
if (window.player) {
window.player.unload()
window.player = null
}
}
this.host.updateSegmentRequestInfo = function(requestInfo) {
requestInfo.withCredentials = false;
}
if(!window.player) {
window.player = new cast.player.api.Player(this.host)
}
this.receiverManager.setApplicationState('Ready To Cast');
this.protocol = cast.player.api.CreateDashStreamingProtocol(this.host)
window.player.load(this.protocol, 0)
We highly recommend that you move to a CAF receiver. Also, CAF has a new queueing API that will handle a playlist of videos.
This used to work perfectly, but currently Game Services appear unable to handle the request issued by TurnBasedMultiplayer.finishMatch() and my players cannot complete their games. Nothing unusual occurs during game play (taking turns), but completion results in response code 400.
What might be going on and what can I do about it?
Logcat:
W/GLSUser ( 887): GoogleAccountDataService.getToken()
I/qtaguid ( 1173): Failed write_ctrl(u 180) res=-1 errno=22
I/qtaguid ( 1173): Untagging socket 180 failed errno=-22
W/NetworkManagementSocketTagger( 1173): untagSocket(180) failed with errno -22
E/Volley ( 1188): [87] tm.a: Unexpected response code 400 for https://www.googleapis.com/games/v1/turnbasedmatches/ChEKCQjrgfqCvgsQAhACGAAgARDruaLm9un3vyg/finish?language=de_DE
E/dwr ( 1188): Failed to finish match: null
W/dwr ( 1188): {"code":400,"errors":[{"message":"Invalid results. results","domain":"global","reason":"InvalidMatchResults"}]}
D/UPDATE_MATCH_RESULT(30627): Status{statusCode=unknown status code: 6504, resolution=null}
Code:
ParticipantResult opponentResult = null;
ParticipantResult creatorResult = null;
if (mMatchData.opponentWonCounter > mMatchData.creatorWonCounter) {
opponentResult = new ParticipantResult(getParticipantId(),
ParticipantResult.MATCH_RESULT_WIN, 1);
creatorResult = new ParticipantResult(
mMatchData.creatorParticipantId,
ParticipantResult.MATCH_RESULT_LOSS, 2);
} else if (mMatchData.opponentWonCounter < mMatchData.creatorWonCounter) {
opponentResult = new ParticipantResult(getParticipantId(),
ParticipantResult.MATCH_RESULT_LOSS, 2);
creatorResult = new ParticipantResult(
mMatchData.creatorParticipantId,
ParticipantResult.MATCH_RESULT_WIN, 1);
} else {
opponentResult = new ParticipantResult(getParticipantId(),
ParticipantResult.MATCH_RESULT_TIE, 1);
creatorResult = new ParticipantResult(
mMatchData.creatorParticipantId,
ParticipantResult.MATCH_RESULT_TIE, 1);
}
Games.TurnBasedMultiplayer
.finishMatch(getApiClient(), mMatch.getMatchId(), data,
creatorResult, opponentResult)
.setResultCallback(
new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
#Override
public void onResult(
TurnBasedMultiplayer.UpdateMatchResult result) {
Log.d("UPDATE_MATCH_RESULT", result
.getStatus().toString());
dismissProgress();
completeMatch();
}
});
EDIT:
I confirm that this works as intended. Also, the player taking the last turn can finish the match and post the final results.
I introduced a bug myself, so sorry for the confusion. (I have a two player setup. The 'creator' wasn't able to finish the match whereas the 'opponent' was. This was caused by participant IDs getting mixed up and code blindness preventing me from identifying the problem.)
Old answer:
Further investigation revealed that these methods had stopped working:
finishMatch(GoogleApiClient apiClient, String matchId, byte[] matchData, ParticipantResult... results)
finishMatch(GoogleApiClient apiClient, String matchId, byte[] matchData, List<ParticipantResult> results)
Whereas this one was still working flawlessly:
finishMatch(GoogleApiClient apiClient, String matchId)
I filed a bug report here: https://code.google.com/p/play-games-platform/issues/list .
EDIT: Acknowledged by Google: http://goo.gl/Ubqy9n
So here's the nasty workaround:
1) Take an extra turn to update the match.
2) Finish the match.
Games.TurnBasedMultiplayer
.takeTurn(getApiClient(), mMatch.getMatchId(), data,
nextParticipantId)
.setResultCallback(
new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
#Override
public void onResult(UpdateMatchResult result) {
mMatch = result.getMatch();
Games.TurnBasedMultiplayer
.finishMatch(getApiClient(),
mMatch.getMatchId())
.setResultCallback(
new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
#Override
public void onResult(
TurnBasedMultiplayer.UpdateMatchResult result) {
Log.d("UPDATE_MATCH_RESULT",
result.getStatus()
.toString());
dismissProgress();
completeMatch();
}
});
}
});
I'm creating a turn based game on the Android platform using the API provided by Google.
At the end of the latest turn (in my case the third one), I'd like to set the winner but I have not found any API that permits this. Naturally I have all the data at the end of the game to set it.
I've not read something in the documentation - does this feature exist or should I handle it myself?
String playerId = Games.Players.getCurrentPlayerId(getApiClient());
String myOponentId = mMatch.getParticipantId(playerId);
opponentResult = new ParticipantResult(myOponentId,
ParticipantResult.MATCH_RESULT_WIN, 1);
creatorResult = new ParticipantResult(playerId,
ParticipantResult.MATCH_RESULT_LOSS, 2);
Games.TurnBasedMultiplayer.finishMatch(getApiClient(), mMatch.getMatchId(),mMatch.getData(), creatorResult,opponentResult )
.setResultCallback(new ResultCallback<TurnBasedMultiplayer.UpdateMatchResult>() {
#Override
public void onResult(TurnBasedMultiplayer.UpdateMatchResult result) {
processResult(result);
}
});