我使用PubNub的WebRTC库启动WebRTC会话并显示本地视频流。如何结束会话,取消订阅并再次删除流?
var phone = window.phone = PHONE({
number : 12345,
publish_key : '...',
subscribe_key : '...',
ssl: true
});
var ctrl = window.ctrl = CONTROLLER(phone);
phone.ready(function(){
ctrl.addLocalStream(document.getElementById("vid-thumb"))
});
答案 0 :(得分:0)
session.hangup()
立即结束会议。
'ended'
回调将针对呼叫两侧的两个关联方触发。
$("#hangup").click(function(){
// End the call
session.hangup();
});
phone.hangup()
有两种方法可以挂断WebRTC调用。 您可以使用电话级方法
phone.hangup()
这将立即挂断所有电话。
或者您可以使用会话级方法session.hangup()
这只会挂断该呼叫会话。
// hangup all calls
phone.hangup();
// hangup single session
session.hangup();
来源:https://github.com/stephenlb/webrtc-sdk/#webrtc-session-hangup