I am using GameKit on a basic level right now. I am able to connect two devices and send messages between them.
I have 3 devices, we'll call them device A, B and C.
I am able to connect A to B, A to C, and B to C, as individual setups.
If I connect A to B, then attempt to connect B to C, Device C will show that Device B is available, but device B continues to spin and say "Looking for available iPod, iPhones..."
In peerPickerController:sessionForConnectionType:
, when I am attempting to connect B to C, I am trying to have device B reuse its same GKSession
that it is using in its connection to A... because if I create a new session on device B, it is able to connect to Device C but drops the connection to device A.
Here is the sessionForConnectionType
:
-(GKSession*)peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type {
// session is a synthesized GKSession
if (session == nil) {
session = [[GKSession alloc] initWithSessionID:nil displayName:@"" sessionMode:GKSessionModePeer];
session.delegate = self;
}
return session;
}
I ended up going with a Server / Client setup, which is easier to manage. This way, there is only one Server PeerID, as opposed to a Server PeerID for every connection. I wasn't able to find many good examples, so I've included the basic GameKit Server / Client code here.