开发者

GameKit: What is the connection type when using GKSession without GKPeerPickerController

I am implementing a BlueTooth and Wifi Based chat program for iPhone. For connection purpose I am using GameKit. But because of some special requirements application I can't use the default GKPeerPickerController. So I instead I created a GKSession and GKSessionDelegate combo to detect the peers. After they find each other, they can chat.

Now I have tested the chat functionality on three mac-minis using simulator, one simulator and one iPod, one iPhone and one Simulator. I am able to chat in all of the above scenarios. But some how the iPhone and iPod won't detect each other.

Also I am curious about type of connection is happening between all these devices. Because theoretically GameKit supports both, BlueTooth and WiFi. Now the problem is that GKPeerPickerCo开发者_如何学JAVAntroller let's one choose specifically between BlueTooth and WiFi, (unfortunately the implementation of WiFi is not documented anywhere.) This is fine, but what about the custom scenario when one implements his or her own GKSession and GKSessionDelegate Combo. When one creates GKSession Object using the only init method available:

– initWithSessionID:displayName:sessionMode:

only configuration option this provides is sessionMode but it has only three options

   GKSessionModeServer,
   GKSessionModeClient,
   GKSessionModePeer,

None of which indicates connection choice between Bluetooth and WiFi.

But I have disabled bluetooth on the iPod and tested it with a mac-mini it works so I guess this is using WiFi. Also in the log I get following line:

DNSServiceRegister callback: Ref=4c3f3d0, Flags=2, ErrorType=0 name=00XGT0H0A..BTChat1 regtype=_0eilkgh5o2mq17._udp. domain=local.

The DNSServiceRegister and udp part make me think the communication is happening over TCP/IP.

So does this mean that when I start with GKSession and GKSessionDelegate the default method of communication is WiFi only, or does it support WiFi and bluetooth both at the same time (though I never got a single indication that BlueTooth connection was happening).

But GameKit is supposed to be mainly about BlueTooth Right? Can anybody put light on the situation about what exactly is happening?

Also have you seen any sample code where somebody has implemented WiFi interface for GKPeerPickerController?


Solved:

OK Found it myself. GKSession and GKSessionDelegate custom implementations as I have mentioned in the question works for both bluetooth and WiFi. Actually the iPhone (JailBroked) I am using had some issues with BlueTooth and possibly that was preventing Gamekit to Work Properly, After hard resetting the phone and turning Airplane mode on off , bluetooth on off a few times got the bluetooth working on the phone. Now the app is working fine in both WiFi and BlueTooth mode.


Do you know if GKPeerPicker behaves in similar way? I mean if selecting NEAR mode allows you to connect over wifi/bluetooth ?

I suspect INTERNET mode is for connecting to remote servers using TCP/IP. Regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜