我有两个简单的 HTML/Javascript 页面。一种用于发起视频通话(主叫方),一种用于接受视频通话(被叫方)。
如 ConnectyCube 的文档中所述,我在双方都登录并首先连接到聊天。
在调用方我执行调用功能:
function callNow(session) {
var extension = {};
session.call(extension, function(error)
{
console.log('calling - ring ring');
//Get calling ringtone ringing
document.getElementById('callingSignal').play();
// work with callbacks
handlingCallReactions();
});
}
//Function for handling the reactions
function handlingCallReactions() {
ConnectyCube.videochat.onUserNotAnswerListener = function onUserNotAnswerListener(
session,
userId
) {
console.group('onUserNotAnswerListener.');
console.log('UserId: ', userId);
console.log('Session: ', session);
console.groupEnd();
};
//If user takes call
//After this, your opponents will get a confirmation in the following callback:
ConnectyCube.videochat.onAcceptCallListener = function(
session,
userId,
extension
) {
console.log('other user accepted call');
};
ConnectyCube.videochat.onRemoteStreamListener = function(
session,
userID,
remoteStream
) {
// attach the remote stream to DOM element
session.attachMediaStream('remoteOpponentVideoElementId', remoteStream);
};
}
观察浏览器控制台,我得到以下输出:
[VideoChat]: _dialingCallback, answerTimeInterval: 60000
所以我认为这部分运作良好,因为该过程正在等待某些事情发生。
在被叫方的另一端,我也登录并连接到聊天(直到这里它运行良好),然后我等待使用以下代码的呼叫到达。
//After this, your opponents will receive a callback call:
//Function for accepting videocalling by callback
ConnectyCube.videochat.onCallListener = function(session, extension) {
var extension = {};
session.accept(extension);
console.log('Im waiting and can take call');
};
ConnectyCube.videochat.onRemoteStreamListener = function(
session,
userID,
remoteStream
) {
// attach the remote stream to DOM element
session.attachMediaStream('remoteOpponentVideoElementId', remoteStream);
};
所述页面(被调用者)的控制台提供以下输出。
[Chat] Connect with parameters {"userId":22222,"password":"bbbbbbbb"}
[Chat] Status.CONNECTING (Chat Protocol - WebSocket) connectycube.min.js:1:454409
[Chat] SENT: <unavailable>
[Chat] RECV: <unavailable>
[Chat] SENT: <unavailable>
[Chat] RECV: <unavailable>
[Chat] SENT: <unavailable>
[Chat] RECV: <unavailable>
[Chat] SENT: <unavailable>
[Chat] RECV: <unavailable>
[Chat] SENT: <unavailable>
[Chat] RECV: <unavailable>
[Chat] Status.CONNECTED at
[Chat] SENT: <unavailable>
[Chat] RECV: <unavailable>
[Chat] SENT: <unavailable>
logged into chat
[Chat] RECV: <unavailable>
我在这里错过了什么才能真正看到电话到达?