开发者

Gamekit how to do p2p wifi connection in iphone

开发者 https://www.devze.com 2022-12-20 17:55 出处:网络
I have to implement multiplayer game in which I am doing p2p communication using both bluetooth and WIFI. Sp开发者_如何学JAVAecially for iphone 1G I have to do connection via WIFI. but in picker defau

I have to implement multiplayer game in which I am doing p2p communication using both bluetooth and WIFI. Sp开发者_如何学JAVAecially for iphone 1G I have to do connection via WIFI. but in picker default connection type is bluetooth. So how to set it to WIFI. Can anyone suggest sample codes for WIFI connection. except GKtank. Thanks in advance.


Hassan’s answer is wrong.

GameKit’s peer-to-peer model can be used in two ways. The Bluetooth classes (that work with PeerPicker, etc.) basically implement Bonjour over Bluetooth. However, if you want to support Wi-Fi and Bluetooth the best thing to do is have a Bonjour based “framework” for establishing the connections, but feed it either from the standard Bonjour services (for Wi-Fi) or from those established by GameKit over Bluetooth.

This post provides some good pointers, but in essence, you will need to use Bonjour to establish your Wi-Fi peer-to-peer connection.

GameKit in iPhone SDK 3.0


add the following method in your code

    - (void)peerPickerController:(GKPeerPickerController *)picker didSelectConnectionType:(GKPeerPickerConnectionType)type
{

picker.connectionTypesMask =  GKPeerPickerConnectionTypeOnline;

}
0

精彩评论

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

关注公众号