This is my first time using the mutlipeer connection infrastructure, and I want programmatic (not with class helpers) control.
Everything works exactly as described when I run my code on two separate devices until the “advertiser” receives a delegate callback:
The browser client delegate recall call is called when it detects an advertiser:
-(void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary *)info{ [[[UIAlertView alloc] initWithTitle:@"Peer Found" message:peerID.displayName delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show]; _session = [[MCSession alloc] initWithPeer:_myPeerID]; _session.delegate = self;
}
Then, the ad client delegate callback is called when it receives an invitation:
-(void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(MCPeerID *)peerID withContext:(NSData *)context invitationHandler:(void (^)(BOOL, MCSession *))invitationHandler{
After inviting the invitation invitation (YES, _session), it seems that the connection between the view client and the advertisement client is never established.
I never received any delegate callbacks (once or twice I got MCSessionStateNotConnected) in MCSession objects on any client device. I would think that I would get an answer to the MCSession delegate call:
-(void)session:(MCSession *)session peer:(MCPeerID *)peerID didChangeState:(MCSessionState)state;
Am I missing something? Anyone else run into this problem?
ios objective-c delegates multipeer-connectivity
Tom newton
source share