GKSession connectToPeer 方法不会超时
我正在努力解决 GKSession 问题。我有一个客户端和服务器,我的客户端尝试与服务器连接,
[_gkSession connectToPeer:peerID withTimeout:10];
如果服务器显式拒绝与 [_gkSession DenyConnectionFromPeer:peerID]
的连接,则客户端的 connectionWithPeerFailed:withError
被正确触发。
但是,如果服务器只是忽略连接或存在其他问题,则客户端将坐在那里尝试连接,直到宇宙热寂为止。超时似乎没有任何影响。
我在文档中看不到任何建议设置超时需要比指定超时间隔更多的内容 - 并且客户端的所有其他 GKSession
委托方法都工作正常。我在这里遗漏了一些明显的东西吗?
I'm struggling with a GKSession problem. I've got a client and server, and my client attempts a server connection with
[_gkSession connectToPeer:peerID withTimeout:10];
If the server explicitly rejects the connection with [_gkSession denyConnectionFromPeer:peerID]
then the client's connectionWithPeerFailed:withError
is triggered correctly.
However, if the server just ignores the connection or there's some other problem, the client will sit there trying to connect until the heat death of the universe. The timeout appears to have no effect whatsoever.
I can't see anything in the documentation that suggests setting up the timeout needs anything more than specifying the timeout interval - and all the client's other GKSession
delegate methods are working fine. Am I missing something obvious here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我的经验,GKSession 非常有问题。我不认为苹果正在修复这些错误。
我要做的是,当您尝试连接到另一方时启动计时器 - 如果连接成功,则取消计时器,当超时时,取消连接。
问候!
from my experience GKSession is VERY buggy. And I don't think apple is fixing these bugs.
What I would do is start a timer when you try to connect to another party - if connection succeeds, cancel the timer, when it times out, cancel the connection.
Regards!