Aaron Bratcher Aaron Bratcher - 1 year ago 196
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download