Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to connect to a Multipeer Connectivity session without an invitation?

I'm trying to create an app similar to FireChat where users are automatically connected to a Multipeer Connectivity session without sending or receiving invitations to connect.

All the tutorials i have seen make use of the MCBrowserViewController. It must be possible to join a session without having to select a peer to connect and send and accept a request to connect if Firechat soes it.

Does anyone know how to do this?

Thanks

like image 532
Juan Carlos Ospina Gonzalez Avatar asked Mar 28 '14 16:03

Juan Carlos Ospina Gonzalez


1 Answers

Instead of using an MCBroswerViewController, you can use MCNearbyServiceBrowser. It will then call a delegate method:

- (void)browser:(MCNearbyServiceBrowser *)browser foundPeer:(MCPeerID *)peerID withDiscoveryInfo:(NSDictionary *)info;

Then you can automatically send an invitation with something like:

[browser invitePeer:peerID
            toSession:self.session
          withContext:nil
              timeout:10];

However, in doing this, I've ran into tons of other problems. So far it seems:

  • If both devices send invitations and accept them, then they randomly disconnect very soon.
  • If both devices are advertising and broadcasting at the same time, then they randomly disconnect.

I'm actually working on an open source library right now to try and do exactly what you're asking for: Connect devices without any invitations or browser necessary (no UI).

Here it is: https://github.com/plivesey/PLPartyTime

However, it is not working yet. I haven't fully solved both issues above, but if you want to check out the code and see what you can work out, go for it. Please let me know of any progress you make though. This framework is frustrating to deal with...

like image 53
plivesey Avatar answered Nov 15 '22 18:11

plivesey