Gamekit how to do p2p wifi connection in iphone

冷暖自知 提交于 2020-01-01 19:35:15

问题


I have to implement multiplayer game in which I am doing p2p communication using both bluetooth and WIFI. Specially 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.


回答1:


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




回答2:


add the following method in your code

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

picker.connectionTypesMask =  GKPeerPickerConnectionTypeOnline;

}


来源:https://stackoverflow.com/questions/2310751/gamekit-how-to-do-p2p-wifi-connection-in-iphone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!