Google Play 游戏服务 - 实时多人游戏 - STATUS_CLIENT_RECONNECT_REQUIRED [英] Google Play Games Services - Realtime Multiplayer - STATUS_CLIENT_RECONNECT_REQUIRED

查看:29
本文介绍了Google Play 游戏服务 - 实时多人游戏 - STATUS_CLIENT_RECONNECT_REQUIRED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 Android 游戏中使用Google Play 游戏服务,但我在调用我重写的 onRoomCreated 方法时遇到了问题.

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

状态码总是和GamesStatusCodes.STATUS_OK不同,实际上等于2(+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 :

GoogleApiClient 处于不一致状态,必须重新连接到解决问题的服务.进一步调用服务使用当前连接不太可能成功.

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.

但是如果我调用 getApiClient().reconnect() 没有任何变化.所以我真的很感激任何帮助.有关信息,getApiClient() 来自我扩展的 GameHelper 类,该类在 Android 示例页面.

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.

推荐答案

onRoomConnected 在客户端尝试创建实时房间时被调用.实时房间可以通过调用 createRoom(RoomConfig) 操作来创建,该操作为当前游戏创建一个实时房间.当前游戏连接到房间的生命周期与此 GamesClient 的生命周期绑定.当客户端断开连接时,玩家将离开房间,并且该玩家的所有点对点连接都将被断开.

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.

您还可以查看此文档,了解如何使用 Google如果您忘记了什么,请使用 Play Developer Console 设置 Google Play 游戏服务.

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.

这篇关于Google Play 游戏服务 - 实时多人游戏 - STATUS_CLIENT_RECONNECT_REQUIRED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆