没有发布Twilio.尝试为另一个应用程序设置新设备时的设备实例

Not releasing Twilio.Device instance on trying to setup new Device for another application

本文关键字:新设备 设置 实例 应用程序 另一个 Twilio      更新时间:2023-09-26

我们正在使用javascript客户端开发一个会议应用程序。

我们有一个场景,用户正在连接到其中一个应用程序,过一段时间后需要连接到不同子帐户下的另一个Twilio应用程序

第二次当我们必须使用连接到另一个Twilio应用程序时

    Twilio.Device.setup(token, { rtc: true,debug:true });

我们得到类似的日志

**[Device] Found existing Device; using new token but ignoring options**  
[Device] Unable to receive incoming calls  
[Device] Registered listener for event type "error"  
[Device] Registered listener for event type "connect"  
[Device] Registered listener for event type "disconnect"  
[Device] Registered listener for event type "ready"  
[Device] Registered listener for event type "offline"  
[Device] Invoke listeners for event type "ready"

**[Application-Ready-EvtHandler] Twilio.Device is now ready for connections : ready
[Application-Ready-EvtHandler] Twilio.Device is now ready for connections : ready (Raised Second Time for old Device)**

以前的设备似乎没有发布

(启动就绪事件的次数==我们必须使用Twilio.Device.Setup的次数)

连接到第一个应用程序后,我无法连接到后续的Twilio应用程序。

随后呼叫Twilio.Device.connect({ agent: currentUserName, debug: true });
抛出异常i,例如"Actionscript中的错误。使用try/catch块查找错误。"

如何使用Twilio.js库切换到后续的Twilio应用程序?

编辑:请注意,这只是IE和firefox中的一个问题,它们不支持web-rtc标准。在chrome中,事件处理程序按照前面提到的进行调用,但它可以工作!

我做错什么了吗?

Jash,我是来自Twilio的Megan。

您在日志中看到的所有内容都是预期的行为。

如果你想在设备之间切换,你需要明确地调用.destroy(),如文档中所述。这将终止活动和挂起的连接,从而触发脱机事件处理程序。在您再次呼叫Twilio.Device.setup()之前,设备将无法建立或接收新连接。