Aaron Bratcher Aaron Bratcher - 3 months ago 17x
Swift Question

MCSession is connecting, but never connected

I have my simulator and phone seeing each other and the one acting as a browser inviting the advertiser into a session. However, the only 2 state changes I see on either side is .Connecting and .NotConnected. I never see .Connected.

Am I supposed to do something to go from .Connecting to .Connected on the advertiser or browser side? I don't see anything in the examples.

I do not have any disconnect statements in my code. Not sure why the connection is being broken.


Ok I tested your source code and here is how I solved it.

I replaced your varibale 'browserSession.session' with '_serverSession' and both the devices are connected properly and can send Data.

_browser?.invitePeer(device.peerID, toSession: _serverSession, withContext: data, timeout: timeoutTime)

Exclusive sessions are required for each peer to peer connection. Enjoy.