javascripthtmlvideochatconnectycube

How to accept a videochat call in ConnectyCube?


I have two simple HTML/Javascript pages. One for initiating videocalls (caller) and one for accepting videocalls (callee).

On both sides I login and connect to chat first as stated in the documentation of ConnectyCube.

On the caller side I execute the call functionality:

    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);
     };
     }

Observing the browser console, I get the following output:

    [VideoChat]: _dialingCallback,     answerTimeInterval: 60000

So I assume this part works well as the process is waiting for something to happen.

On the other side of the callee, I login and connect to chat as well (until here it works well) and then I wait for a call to arrive with the following code.

    //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);
    };

The console of said page (the callee) gives the following output.

[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>

What am I missing here to actually see the call arrive?


Solution

  • Your code is correct,

    what I can recommend to check is how you create session object

    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);
    

    I recommend to check what is inside calleesIds at your side. I guess the callee does not receive anything because his user id is not in calleesIds array at caller's side.

    https://developers.connectycube.com/js/videocalling?id=create-video-session