0

Iam using Multipeer connectivity Feature.

Consider A,B,C are connected in a session created by A.Suppose B want to get out of the session without disconnecting the session ( [session Disconnect] ) or exiting the app .Is that possible?. Does turning off the advertiser of B,disconnects it from the session?. Or is there any other way? Please help!

DHEERAJ
  • 1,478
  • 12
  • 32
  • Are you asking how do I release B from the session with A without affecting the session between A and C? – 300baud Feb 22 '15 at 22:53
  • Yes exactly.. any hope???? – DHEERAJ Feb 23 '15 at 04:04
  • did the answer help? If so, appreciate confirmation – 300baud Feb 24 '15 at 03:53
  • Any other option other than multisession???? – DHEERAJ Feb 24 '15 at 06:53
  • not that I know of - if you explain your use case better, there maybe a better solution. Fundamentally you either disconnect a session with 1 peer in it or up to 8. Why not just send a message to your other peer to "go-offline". The peer is still in session, but won't communicate until told to "resume" – 300baud Feb 25 '15 at 21:02

2 Answers2

0

In your circumstance, there's nothing stopping you creating multiple sessions with a single peer (I have a solution working which so far is running fine with up to 16 peers). BTW, this answer may also help

Option 1: A->B (session 1) A->C (session 1)

Option 2: A->B (session 1) A->C (session 2)

In option 2, you can simply [session disconnect] for A->C without impacting A->B

- (void)advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(MCPeerID *)peerID withContext:(NSData *)context invitationHandler:(void(^)(BOOL accept, MCSession *session))invitationHandler
...
    terminalDev.session = [self newSession];
    terminalDev.peerID = peerID;
    invitationHandler(YES, terminalDev.session);

- (void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary *)info
           // save the peerID for later communications
            hostDevice.peerID = peerID;

            // and ask the browser to invite the peer(host) to the session for this device
            hostDevice.session = [self newSession];

            DDLogDebug(@"Inviting Host %@ to session %@", remotePeerName, hostDevice.session);
            [browser invitePeer:peerID toSession:hostDevice.session withContext:nil timeout:30.0];
Community
  • 1
  • 1
300baud
  • 540
  • 4
  • 17
0

The Apple sample application for the MCMultipeerConnectivity framework contains the use-case you describe.

They create a wrapper class to handle the MCSession, and each MCSession maintains an array of connected MCPeerIDs.

Source: https://developer.apple.com/library/ios/samplecode/MultipeerGroupChat/Introduction/Intro.html