我有两个简单的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>我在这里错过了什么才能看到电话的到来?
发布于 2018-08-22 08:30:22
你的代码是正确的
我推荐您检查如何创建会话对象。
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
https://stackoverflow.com/questions/51956367
复制相似问题