简体   繁体   English

GKSession与2台以上的设备断开连接

[英]GKSession disconnects with more than 2 devices

We are using GKSession to setup a game. 我们正在使用GKSession来设置游戏。 This works great with 2 devices, with one device being setup with GKSessionModeServer and the other GKSessionModeClient. 这适用于2个设备,其中一个设备使用GKSessionModeServer和另一个GKSessionModeClient设置。

However, as soon as we have 2 or more clients (3 devices; 1 host and 2 clients) one of the clients will disconnect at random at some point. 但是,只要我们有2个或更多客户端(3个设备; 1个主机和2个客户端),其中一个客户端将在某个时刻随机断开连接。 No error handlers are called (didFailWithError or connectionWithPeerFailed), only didChangeState on both server and client. 没有调用错误处理程序(didFailWithError或connectionWithPeerFailed),只有服务器和客户端上的didChangeState。 The disconnect usually happens within a minute, sometimes much less. 断开通常在一分钟内发生,有时甚至更少。

All devices (2 iPhones and 1 Simulator) are on the same wireless network. 所有设备(2个iPhone和1个模拟器)都在同一个无线网络上。 One physical device runs iOS6.0.1, and the other 5.1.1, and both can keep connected when connecting to the simulator. 一个物理设备运行iOS6.0.1,另一个运行5.1.1,并且在连接到模拟器时都可以保持连接。 It is only with 3 devices (2 real, 1 simulated) that the problem happens. 只有3个设备(2个真实,1个模拟)才会出现问题。

Any help would be great appreciated. 任何帮助将非常感谢。

I have the same problem but in my app this problem happens when i connect the third or the forth client (randomly). 我有同样的问题,但在我的应用程序中,当我连接第三个或第四个客户端(随机)时,会出现此问题。 The server gets the disconnection event, but the client freezes. 服务器获取断开连接事件,但客户端冻结。 I noticed that is always the last client connected being disconnected few seconds later. 我注意到,几秒钟之后,连接的最后一个客户端始终是断开的。 I can't understand How to solve the problem, i found an app called idea flight that manages client/server connections through gamekit and that can manage up to 15 clients (as specified in GameKit documentation), i tested it and it works. 我无法理解如何解决问题,我发现了一个名为idea flight的应用程序,通过gamekit管理客户端/服务器连接,并且可以管理多达15个客户端(如GameKit文档中所指定),我测试了它并且它有效。 It's 3 days that i'm losing my mind on the code, and i'm thinking about switching to standard socket communication, but i will lose Bluetooth support. 这是3天,我在代码上失去了理智,我正在考虑切换到标准套接字通信,但我将失去蓝牙支持。

EDIT: I found the reason of the problem. 编辑:我找到了问题的原因。 This problem happens when the network is composed by a mix of devices running both iOS 6 and previous iOS versions. 当网络由同时运行iOS 6和以前的iOS版本的设备组成时,会发生此问题。 If the network is composed only by devices running iOS6 or only previous versions everything is fine. 如果网络仅由运行iOS6的设备组成,或者仅由以前的版本组成,则一切都很好。 More precisely this isn't a crash, but the client that gets stuck has some threads that are waiting on a mutex, which means that the GameKit leads our app to a deadlock. 更确切地说,这不是崩溃,但是卡住的客户端有一些等待互斥锁的线程,这意味着GameKit导致我们的应用程序陷入僵局。 Reading on the Apple Developer's Forum I've known that some users have reported this bug directly to Apple, but Apple didn't answer to them. 在Apple开发者论坛上阅读我已经知道有些用户直接向Apple报告了这个错误,但Apple没有回答这些问题。 So, for now, the only way to ensure apps based on GKSession to run safely is to support only iOS 6 or to write a network communication system from scratch with Bonjour, sockets and low level BlueTooth API. 因此,目前,确保基于GKSession的应用程序安全运行的唯一方法是仅支持iOS 6或使用Bonjour,套接字和低级BlueTooth API从头开始编写网络通信系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否有更可靠的 GKSession 替代方案允许在 3 个以上设备之间进行 P2P? - Are there more reliable alternatives to GKSession which allow P2P between more than 3 devices? 相互连接3个以上的ios设备 - Connect more than 3 ios devices with each other 使用GKSession通过不同的WiFi网络连接2个设备 - connecting 2 devices over different WiFi network using GKSession GKSession将获取后台处于后台的其他设备的对等ID - GKSession will get peer ids of other devices which are in background iPhone对等2对等Connection ..是否可以连接到多个设备? - iPhone peer 2 peer Connection .. Is there a way to connect to more than 1 devices? Bonjour网络(发送消息)到两个以上的iOS设备 - Bonjour networking (sending messages) to more than two iOS devices kCLErrorDomain错误5:CLLocationManager不允许我在iPhone 7上注册10个以上的设备 - kCLErrorDomain error 5 : CLLocationManager won't let me register more than 10 devices on my iPhone 7 iPhone企业计划是否可以让我对100多种设备进行Beta测试? - Will iPhone enterprise program allow me to beta test with more than 100 devices? 使用Mac OS X的GKSession - GKSession with Mac OS X GKSession:发送一个字符串数组 - GKSession: Sending an Array of Strings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM