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

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

问题描述

我试图在我的 Android 游戏中使用
Google Play游戏服务实现实时多人游戏,但是我遇到了一个问题,

  @Override $ b code> onRoomCreated  $ b 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 参数为空),这意味着根据 Google $ b


GoogleApiClient处于不一致状态,必须重新连接
服务才能解决问题。


如果我打电话给> code> getApiClient()。重新连接()。所以我会很感激任何帮助。有关信息, getApiClient()来自我扩展的 GameHelper 类,它来自< a href =https://github.com/playgameservices/android-basic-samples =nofollow noreferrer> Android样本页面。

解决方案

当客户端尝试创建实时房间时,会调用onRoomConnected。实时房间可以通过调用createRoom(RoomConfig)操作来创建,该操作为当前游戏创建实时空间。当前游戏与房间连接的生命周期必然与此GamesClient的生命周期有关。当客户断开连接时,玩家将离开房间,任何此玩家的点对点连接都将被拆除。



您可以访问这个 游戏/服务/控制台/启用#step_1_sign_in_to_the_dev_consolerel =nofollow>文档,了解如何使用Google Play开发者控制台设置Google Play游戏服务。


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.

解决方案

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.

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

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