Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

android - Google Play Games Services - Realtime Multiplayer - STATUS_CLIENT_RECONNECT_REQUIRED

I am trying to implement a real-time multiplayer in my Android game using the Google Play Games Services but I am facing an issue when the onRoomCreated method, that I overrided, is called.

  @Override
  public void onRoomCreated(int statusCode, Room room) {
    if (statusCode != GamesStatusCodes.STATUS_OK) {
      stopKeepingScreenOn();
      showGameError();
      return;
    }
    roomId = room.getRoomId();
    showWaitingRoom(room);
  }

The status code is always different of GamesStatusCodes.STATUS_OK and actually equal to 2 (+ the room parameter is null), which means according to Google :

The GoogleApiClient is in an inconsistent state and must reconnect to the service to resolve the issue. Further calls to the service using the current connection are unlikely to succeed.

But there is no change if I call getApiClient().reconnect(). So I would really appreciate any help. For information, getApiClient() comes from the GameHelper class that I extend and which is provided in the library from the Android samples page.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

onRoomConnected is called when the client attempts to create a real-time room. The real-time room can be created by calling the createRoom(RoomConfig) operation which create a real-time room for the current game. The lifetime of the current game's connection to the room is bound to this GamesClient's lifecycle. When the client disconnects, the player will leave the room and any peer-to-peer connections for this player will be torn down.

You can visit this page for more information.

You can also check this document on how to use the Google Play Developer Console to set up Google Play games services if you forgot something.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...