Hi,
I'm trying to understand the basic steps required for a game I'm trying to make using GameKit for bluetooth connections. I only have 1 device, so I can't test out my ideas very easily - therefore, I'd really appreciate any help you could give.
The game involves a maximum of 2 players over bluetooth via GameKit and the only data to send/receive is a 'shot' which includes position and direction data only.
This is what I think should happen, I really just want someone to point out any mistakes I've made:
The game starts by presenting a GKPeerPickerController with a connectionTypeMask of 'GKPeerPickerConnectionTypeNearby' and setting it's delegate to 'self'.
The GKPeerPickerController delegate method 'peerPickerController:didConnectPeer:toSession:' is implemented and sets the sessions dataReceiveHandler to self. The peerID is added to an NSMutableArray which holds all peer IDs connected. (There should only be 1 peer connected at any time).
To enforce only 1 peer connection per game the method 'session:didReceiveConnectionRequestFromPeer:' checks the 'count' property of the NSMutableArray which holds the connected peerIDs. If 'count'>0 then we respond by calling: 'denyConnectionFromPeer:' else, we call: 'acceptConnectionFromPeer:error:'
To send a shot, the game calls: 'sendData:toPeers:withDataMode:error:'
To receive shots, the game responds to: 'receiveData:fromPeer:inSession:context:'
Are there any steps missing? For example, if a user tries to connect to me before I connect to them, what will happen with my GKPeerPickerController? How do I know to dismiss it?
Please help! This is pretty urgent and without another iPhone/iPod I can't test...
Best Regards,
David