问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/28309070/mcsession-is-connecting-but-never-connected