Search code examples
androidlibgdxmultiplayergoogle-play-services

Google play services, sign in succeeded but error on create room


This is very similar to a problem someone else had on here except that the solution that fixed theirs is not my problem. (Note: I am using libgdx to develop this but I'm pretty sure that has nothing to do with this issue since the signing part is working)

@Override
public void startQuickGame() {
    boolean signedIn = getSignedIn();
    System.out.println(signedIn);
     // automatch criteria to invite 1 random automatch opponent.  
    // You can also specify more opponents (up to 3). 
    Bundle am = RoomConfig.createAutoMatchCriteria(1, 4, 0);

    // build the room config:
    RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder();
    roomConfigBuilder.setAutoMatchCriteria(am);
    RoomConfig roomConfig = roomConfigBuilder.build();

    // create room:
    aHelper.getGamesClient().createRoom(roomConfig);
}

And here is where I check when the room is created.

final static int RC_WAITING_ROOM = 10002;
@Override
public void onRoomCreated(int statusCode, Room room) {
    if (statusCode != GamesClient.STATUS_OK) {
        System.out.println(statusCode);
        return;
    }
    // get waiting room intent
    Intent i = aHelper.getGamesClient().getRealTimeWaitingRoomIntent(room, Integer.MAX_VALUE);
    startActivityForResult(i, RC_WAITING_ROOM);
}

The status code I'm getting there is 6 which corresponds to

STATUS_NETWORK_ERROR_OPERATION_FAILED

I'm definitely signed in before it creates the room as signedIn is always true.

I have multiplayer enabled on my dev console

My package name is matching, and I'm even seeing this in my api console.

games.rooms.create

error messages


Solution

  • Figured it out. Misleading Javadoc plus human error.

    enter image description here

    I took that second argument to mean the max number of players, not the max number of players to invite, hence you + 3 others.

    So here is the culprit in my code =p

    Bundle am = RoomConfig.createAutoMatchCriteria(1, 4, 0);
    

    Should be

    Bundle am = RoomConfig.createAutoMatchCriteria(1, 3, 0);
    

    And now it works just fine =)