GKPeerPickerController的连接故障 [英] Connection trouble with GKPeerPickerController

查看:82
本文介绍了GKPeerPickerController的连接故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GKSession和GKPeerPickerController开发iOS游戏.我发现连接两个iOS设备的过程缓慢且不可靠,即使它们彼此相邻也是如此.我们将我的设备称为设备A"和设备B".

I am working on an iOS game with GKSession and GKPeerPickerController. I am finding that the process of connecting two iOS devices is slow and unreliable, even if they are right next to each other. Let's call my devices "device A" and "device B."

以下是通常发生的情况:

Here is what typically happens:

  1. 在每台设备上,我都点击了我的应用程序的连接"按钮.然后,每个设备都会显示"iPad,iPhone或iPod touch"窗口.

  1. On each device, I hit my app's connect button. Each device then shows the "iPads, iPhones, or iPod touches" window.

通常很快,两个设备都注意到另一个设备存在.

Usually pretty quickly, the two devices each notice that the other exists.

然后我告诉其中一个设备(例如设备A)连接到另一个.

I then tell one of the devices (say device A) to connect to the other.

很快,设备B的窗口显示设备A不可用.

Pretty quickly, device B's window says that device A is not available.

这是令人讨厌的地方.从大约1秒钟到永不停止的一段时间后,设备B上弹出一个窗口,提示设备A要连接,并询问设备B是否要接受连接.

This is where it gets annoying. After a period of time ranging from about 1 second to never, a window pops up on device B saying that device A wants to connect, and asking device B whether or not it wants to accept the connection.

如果弹出以上窗口,则一切正常.但这有时会花费很长时间,有时甚至根本不会发生.

If the above window does pop up, everything proceeds normally. But this sometimes takes a long time, and sometimes does not happen at all.

我有3台设备,无论我使用哪2台设备,我都遇到类似的问题.

I have three devices, and I have similar problems no matter which two I am using.

对此我能做些什么吗?

我的连接方法非常简单:

My connection method is pretty straightforward:

-(void) findPeerPickerOpponents {
    GKPeerPickerController *picker;
    picker = [[GKPeerPickerController alloc] init]; 
    picker.delegate = self;
    [picker show]; 
    [self.connectionDelegate disableIdleTimer];
}

推荐答案

我完全放弃了peerPickerController.查看Apple的GKRocket示例代码. -使用GKSession和对等点的表视图.由于尚不清楚的原因,目前我的设备上存在一些错误,但是我使用了基本类:GameLobby和SessionManager来使设备连接良好.还具有不将您限制到一个同伴的优点.

I gave up on peerPickerController completely. Check out Apple's GKRocket example code. - Uses GKSession and tableviews of peers. It is a bit buggy on my devices right now, for reasons I am not clear on, but I used the basic classes: GameLobby and SessionManager to get devices hooking up pretty well. Also has the advantage of not restricting you to one peer.

这篇关于GKPeerPickerController的连接故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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