1

我正在开发一个 iPad 应用程序(“服务器”),它需要与多达 4 个 iPhone/iPod Touches(客户端)进行通信。我应该为每部 iPhone 创建 4 个 GKSession 吗?我是否应该有 1 个连接所有 5 个设备的 GKSession,如果我这样做了,每个 iPhone 是否能够“看到”其他设备(理想情况下,这不应该发生,因为它会让事情变得简单)?这些应用程序将有点像 iPad 上的拼字游戏应用程序(不是在功能上,而是在想法上)。

有没有人有任何gamekit示例代码或好的链接?

我下载了 GKTank,但无法让 iPad 和 iPhone 完成连接。我什至都关闭了两个wifi,但他们一直在等待连接。

4

1 回答 1

0

i recently implemented something like this. I used this as a base and this as a good reference.

in my ipad viewcontroller i have a button that sets up the session

session = [[GKSession alloc] initWithSessionID:@"mySessionId" displayName:[[UIDevice currentDevice] name] sessionMode:GKSessionModeServer];
session.delegate = self;
[session setDataReceiveHandler: self withContext:nil];
session.available = YES;

for when you are ready for clients to connect. in the iphone remote viewcontroller i use the GKPeerPickerControllerDelegate and create a peer session when it finds your server.

for me, walking throught the first guide helped me get connected, and the reference material helped me understand what all was going on.

in your server, you then have your list of peers (like the the objectgraph example) that you can send messages individually to a peer, or to all peers from the server.

于 2010-09-02T20:57:05.593 回答