GKSession:暂停应用程序后不可见
我正在使用 GameKit 工作一段时间。几乎一切都工作正常。我有一个主要问题:恢复后未调用 session:peer:didChangeState:
方法。
在 Apple 示例 GKRocket 中,如果应用程序挂起(willTerminate),会话将被销毁,并在应用程序返回时设置(willResume)。对于我的应用程序来说,保持会话持续就好了。
在日志中我可以看到,当应用程序挂起时,会调用状态为 GKPeerStateUnavailable 的 session:peer:didChangeState:
,但在恢复使用 GKPeerStateAvailable 的调用后不会显示。会议可用。但即使是新客户也找不到该设备。
我使用会话模式服务器/客户端。
预先感谢您的帮助!
I am working around for a while with GameKit. Almost everything works fine. I have a major Problem with the session:peer:didChangeState:
Method not beeing called after resuming.
In the Apple example GKRocket the session is destroyed if the app suspends(willTerminate) and setup when it comes back(willResume). For my app it would be nice to keep the session up.
In the Logs i can see, that session:peer:didChangeState:
with state GKPeerStateUnavailable is called when the app suspends, but after resuming the call with GKPeerStateAvailable doesnt show up. The session is available. But even new clients cant find the device.
I use the SessionModes Server/Client.
Thanks in advance for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我前段时间正在玩会话,但有一些建议...
- 恢复后,如果您尝试将打包的数据从睡眠设备发送到唤醒设备,会发生什么?它通过了吗?
-您需要 GKPeerStateUnavailable / available 吗?根据我的经验,您需要使用的只是 applicationDidBecomeActive 和 applicationWillResignActive 方法:当您要睡觉时,您将 GAME_PAUSED 发送到其他设备,当醒来时 - GAME_UNPAUSED。如果用户将应用程序置于睡眠状态然后关闭它 - 好吧,运气不好,另一个玩家将永远坐在那里(因此您可以给他一个退出主菜单的选项)。这种方法适用于苹果(就批准而言) - 在两个应用程序上进行了测试。
问候!
I was playing with sessions some time ago, but have some suggestions...
-after resuming, what happens if you try to send packed from device which was sleeping to device which was awake? does it go through ?
-do you need GKPeerStateUnavailable / available ? From my experience all you need to use are applicationDidBecomeActive and applicationWillResignActive methods: when going to sleep you send GAME_PAUSED to other device, when awake - GAME_UNPAUSED. If user puts app to sleep and then closes it - well, bad luck, the other player will sit there forever (so you can give him an option to quit to main menu). This approach works with apple (in terms of approval) - tested on two apps.
Regards!