MCSession is connecting, but never connected

烂漫一生 提交于 2019-12-13 01:29:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!