0
私たちのアプリケーションでは音声通信にTwilioを使用しています。Twilio Device.destroy()はデバイスとイベントハンドラを解放しません
音声通話をするときは、以下のようにTwilioデバイスを設定します。 呼び出しが成功しなかった場合は、もう一度関数を呼び出してもう一度呼び出すことになります。
私の質問は機能を破壊しないのですが、イベントハンドラも削除しますか?そして、なぜ破壊を呼び出す後にセットアップを呼び出すときに、「[デバイス]が既存のデバイスを検出しました;新しいトークンを使用していますが、オプションを無視していますか?
function setupTwilio(token) {
if (angular.isFunction(Twilio.Device.destroy)) {
console.log('Destroying Twilio device');
Twilio.Device.destroy(); // Destroy before setup incase we have already run this
}
startEventHandlers(); // add event handlers for Twilio events e.g. connect, disconnect
trySetup = function() {
var params = { debug: (DEBUG ? true : false) };
if (DEBUG) {
console.log('trying the twilio setup at ' + new Date());
console.log(Twilio.Device.instance);
}
// Twilio will not hit the handlers specified in startEventHandlers until a successful setup has been created, so run try catch here
try {
Twilio.Device.setup(token, params);
} catch (e) {
if (DEBUG) {
console.log('TwilioSetup uncaught error: ' + e);
}
}
};
if (angular.isDefined(token)) {
trySetup();
}
}