我有两个简单的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>


我在这里错过了什么才能真正看到电话到达?

最佳答案

您的代码是正确的,

我建议检查的是如何创建会话对象

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

关于javascript - 如何在ConnectyCube中接受视频聊天调用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51956367/

10-12 14:09