MCSession正在连接,但从未连接 [英] MCSession is connecting, but never connected

查看:131
本文介绍了MCSession正在连接,但从未连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的模拟器和电话互相看到,一个模拟器充当浏览器,邀请广告商参加会话.但是,我在任一侧看到的唯一两个状态更改是.Connecting和.NotConnected.我从未见过.已连接.

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.

我应该做些什么从.Connect到.Connect在广告商或浏览器端进行连接?我在示例中什么都看不到.

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.

推荐答案

好吧,我测试了您的源代码,下面是我的解决方法.

我将您的变量'browserSession.session'替换为'_serverSession',并且两个设备均已正确连接并且可以发送数据.

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.

这篇关于MCSession正在连接,但从未连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆