我有两个简单的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>
我在这里想看到电话真的错过了什么?
答案 0 :(得分:1)
您的代码正确,
我建议检查的是如何创建会话对象
var calleesIds = [56, 76, 34]; // User's ids
var sessionType = ConnectyCube.videochat.CallType.VIDEO; // AUDIO is also possible
var additionalOptions = {};
var session = ConnectyCube.videochat.createNewSession(calleesIds, sessionType, additionalOptions);
我建议检查一下您身边的 calleesIds 中的内容。我猜被叫方什么都不会收到,因为他的用户ID不在呼叫方的 calleesIds 数组中。
https://developers.connectycube.com/js/videocalling?id=create-video-session