19

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);

        }
    }
Jaeger
  • 1,646
  • 8
  • 27
  • 59
  • 1
    app_id is also correct. Firebase and Google Play console projects are linked with the correct Google Play App & Service. – Jaeger Jul 25 '18 at 21:07
  • I already expected this to not be answered even while having a bounty on it. Therefore on the first day i went to make my own way of Multiplayer using Firestore. I did it without using the Firebase functions (bad idea i know) and after 4 days of working I have finished it up. It's working with rooms and connections and listeners..etc just like like the GP Multiplayer API. Considering that i followed the provided example in the github and experiencing an old error used in the old API while using the new SignInAPI is completely redundant. – Jaeger Aug 01 '18 at 23:08

0 Answers0