如何在 RingCentral Web Phone 客户端库中注销用户代理?

How do I un-register user agent with the RingCentral Web Phone Client Library?

我可以看到我必须使用 /restapi/v1.0/client-info/sip-provision 基于此 API 资源的端点注册一个 SIP 设备:https://developers.ringcentral.com/api-docs/latest/SipDeviceRegistration.html

基于RingCentral Web Phone Client Library, and using the RingCentral JS-SDK我能够配置 SIP 设备:

// Setup RingCentral
var RC = require('ringcentral');
var sdk = new RC({
    server: process.env.RC_SERVER,
    appKey: process.env.RC_APP_KEY,
    appSecret: process.env.RC_APP_SECRET 
});

var platform = sdk.platform();

// Login
platform
    .login({
        username: process.env.RC_USERNAME,
        extension: process.env.RC_EXTENSION,
        password: process.env.RC_PASSWORD 
    })
    .catch(function(e) {
        console.error('RC LOGIN ERROR: ', e);
        throw e;
    });

// SIP Provision
platform
            .post('/client-info/sip-provision', {
                sipInfo: [{transport: 'WSS'}]
            })
            .then(function(res) {
                io.emit('sipProvisionResponse', res.json());
            })
            .catch(function(e) {
                console.error(e);
                throw e;
            });

设备的 SIP 配置完成后,我将使用该信息来实例化 WebPhone

var webPhone;
var rcSipProvision; // Is set to result of request to /restapi/v1.0/client-info/sip-provision
rcSipProvision = data.sipInfo[0] || data.sipInfo;;
//console.log('RingCentral: ', RingCentral);
webPhone = new RingCentral.WebPhone(data, {
  logLevel:1,
  audioHelper: {
    enabled: true, // enables audio feedback when phone is ringing or making call
    incoming: '/audio/incoming.ogg', // path to audio file for incoming call
    outgoing: '/audio/outgoing.ogg' // path to audio file for outgoing call
  }
});
$callButton.removeAttr('disabled');

webPhone.userAgent.on('invite', onInvite);
webPhone.userAgent.on('connecting', onConnecting);
webPhone.userAgent.on('connected', onConnected);
webPhone.userAgent.on('disconnected', onDisconnected);
webPhone.userAgent.on('registered', onRegistered);
webPhone.userAgent.on('unregistered', onUnregistered);
webPhone.userAgent.on('registrationFailed', onRegistrationFailed);
webPhone.userAgent.on('message', onMessage);

使用上面的方法,我可以使用 Web phone 客户端库邀请其他人使用 WebRTC 和 webPhone.userAgent.invite 进行通话。如果用户关闭浏览器并终止会话怎么办?如何通过终止 SIP 提供和取消注册用户代理来确保我的应用程序更新 RingCentral?

我不知道如何取消注册 RingCentral Web Phone Client Library since this is included in the creation of the WebPhone from either the RingCentral Web Phone Client Library, the RingCentral JS SDK, or the RignCentral API Reference for SIP Device Registration 中引用的用户代理。

我没有看到 WebPhone 公开注销用户代理的能力,我正在尝试弄清楚如何正确执行此操作。

欢迎任何帮助。

RingCentral Web Phone 是 SIP.JS 的自定义包装器,因此要注销您只需调用 SIP.JS 的方法:http://sipjs.com/api/0.7.0/ua/#unregisteroptions

你的情况是 webPhone.userAgent.unregister