问题
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