Js Opentok (Tokbox) Show waiting Status.

689 views Asked by At

I am creating an conference page where two users can have a video conference call.

for video conference i am using Opentok Tokbox facility ,

Problem :

consider a scenario where User 1 joins the conference room and he is not accompanied by the second user and he is waiting for the second user to join the conference , so in that case i wanted to display a note to the user "Please wait for the user"

and once the user joins in then the message should be replaced with the video Conference Meeting as done in the below js code,

  session.connect(token, function(error) {           
     var publisher = OT.initPublisher('video_conf',pubOptions);              
     session.publish(publisher);         
   });

<div id="video_conf" class="video_conf">Here i want the note to be Displayed</div>

I am using the above code to publish the video conference after creating the session where video_conf is the div class where the conference is getting published.

Thanks a lot for the help :)

1

There are 1 answers

2
Dave Mun On BEST ANSWER

You would need to connect to the session by default, as you can't see session events if you are not connected. You should have the waiting page activate in session.connect(), and have a session event listener to deactivate the waiting page when someone joins. Here is an example session event listener and handler:

session.connect(token, function(error) {           
   var publisher = OT.initPublisher('video_conf',pubOptions);              
   session.publish(publisher);         
   enableWaitingSign();
});

session.on('streamCreated', function (event) {
  //Someone else has joined the session  
  disableWaitingSign();
  session.subscribe(event.stream);
});

JS documentation on sessions: https://tokbox.com/developer/sdks/js/reference/Session.html