0

I ran into a strange problem. In my multiplayer game user decides how many opponents they want to play with(up to 3), and after they've decided I create an autoMatchCriteria like this-

Bundle am = RoomConfig.createAutoMatchCriteria(opponentCount, opponentCount, 0);

And create a room-

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

        // create room:
        Games.RealTimeMultiplayer.create(((MainActivity) getActivity()).getGoogleApiClient(), roomConfig);

This triggers RoomUpdateListener's onJoinedRoom() or onRoomCreated() accordingly. And while the user waits in a waitingRoom they gets room status updates in RoomStatusUpdateListener's onPeersConnected() when a peer gets connected and after minimum required players are connected the game play can be started.

But when user selects more then one opponents, onPeersConnected() only gets called once if at all and the connected player keeps waiting indefinitely until they leave the room.

I tried it with google's waiting room ui and strange enough it worked with it for every opponent count.

So if anyone can point me to what am I doing wrong, would be a great help. Thank you.

1 Answers1

0

Based from this thread, if you set min to 1 and max to 3, you might be getting a 2 player game. To have players up to 3, set MIN_OPPONENTS and MAX_OPPONENTS to 3, and handle the game start logic from your code. If the logic gets more complicated, it might make sense to elect a "server". You can do that, for example, by saying that the client with the lowest Participant ID (lexicographically) is the server. Saying "whoever created the game is the server" is no good, because when automatching, everyone thinks they created the game. Hope this helps!

abielita
  • 13,147
  • 2
  • 17
  • 59