Google Play Games Services - Realtime Multiplayer - STATUS_CLIENT_RECONNECT_REQUIRED(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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Google Play 游戏服务 - 实时多人游戏 - STATUS_CLIENT
基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01