I'm trying to connect via a quick match. I have everything enabled. APIs are enabled, the debug key and production key are added in the Oauth2 list in Google API Console.
Real-Multiplayer is enabled and game-service is published. I'm trying some sample code in my game, plus i'm signing the user.
I'm getting error 2 in onJoinedRoom
I'm trying to sign-in using this:
public void signInSilently() {
mGoogleSignInClient.silentSignIn().addOnCompleteListener(getActivity(),
new OnCompleteListener<GoogleSignInAccount>() {
@Override
public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
if (task.isSuccessful()) {
//onConnected(task.getResult());
Utils.logDebug("OnlineFragment.startSignInIntent()","onComplete, isSuccessful.");
onConnected(task.getResult());
} else {
startSignInIntent();
Utils.logDebug("OnlineFragment.startSignInIntent()","onComplete, NOT isSuccessful.");
task.getException().printStackTrace();
}
}
});
}
It's always onConnected
private void onConnected(GoogleSignInAccount googleSignInAccount){
mRealTimeMultiplayerClient = Games.getRealTimeMultiplayerClient(getActivity(), googleSignInAccount);
startQuickGame();
}
After connecting, I'm starting the new quick match:
private void startQuickGame() {
if(getActivity() != null){
// auto-match criteria to invite one random automatch opponent.
// You can also specify more opponents (up to 3).
// TODO: Make the first param's value 2
Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(1, 1, ROLE_ANY);
// build the room config:
RoomConfig roomConfig =
RoomConfig.builder(mRoomUpdateCallback)
.setOnMessageReceivedListener(mMessageReceivedHandler)
.setRoomStatusUpdateCallback(mRoomStatusCallbackHandler)
.setAutoMatchCriteria(autoMatchCriteria)
.build();
// prevent screen from sleeping during handshake
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// Save the roomConfig so we can use it if we call leave().
mJoinedRoomConfig = roomConfig;
// create room:
mRealTimeMultiplayerClient.create(mJoinedRoomConfig);
}
}
Then I'm getting the error in the listener (Only the mentioned function from the listener has been included, other functions are not getting called)
private RoomUpdateCallback mRoomUpdateCallback = new RoomUpdateCallback() {
@Override
public void onRoomCreated(int code, @Nullable Room room) {
// Update UI and internal state based on room updates.
if(room != null)
Log.d("SignInGoogleOnlineFrag", "Room isn't null");
if(code == GamesCallbackStatusCodes.OK)
Log.d("SignInGoogleOnlineFrag", "OK");
if (code == GamesCallbackStatusCodes.OK && room != null) {
Log.d("SignInGoogleOnlineFrag", "Room " + room.getRoomId() + " created.");
} else {
Log.w("SignInGoogleOnlineFrag", "Error creating room: " + code);
// let screen go to sleep
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}