Twilio-video.js: How to differentiate between localParticipant disconnect and room completed in JS?

Created on 23 Jan 2018  ·  9Comments  ·  Source: twilio/twilio-video.js

🏷 Question

Is there any way to have a listener 'roomCompleted' or something similar? in JS!

I notice that room.on('disconnected') is triggered if the room is completed on the backend or if the local participant left the room
how can I differentiate between both cases?

enhancement

Most helpful comment

This was released in twilio-video.[email protected].

All 9 comments

Hi @alielkhateeb ,

Can you elaborate on what you mean by "roomCompleted". Does it mean that everybody else but the LocalParticipant have left the Room? If so, you can use the "participantDisconnected" event as follows:

room.on('participantDisconnected', () => {
  if (room.participants.size === 0) {
    console.log('Room completed');
  }
});

Please let me know if you have a different definition of "roomCompleted".

Thanks,

Manjesh Malavalli

Hey @manjeshbhargav

No I didn't mean that, cause when everybody leaves the room, they can still rejoin, and the room status is set to completed automatically if it was idle for 5 mins, this is the kind of completed I meant.

It can happen in one of 2 situations:

  • Someone call the rest api through:
    $client->video ->rooms("RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") ->update("completed");
  • The room has no participants for 5 mins.

So what I want to do is, when someone call the Rest API as mentioned above to force a room to completed status, I want the participants in that room to be kicked LOL.

When I use room.on('disconnected') listener it is fired whenever the user leave the room, not only when the room is set to completed. So that is my question, how to differentiate between a local participant leaving the room and someone set the room status to completed through the Rest API?

Sorry if I am not clear enough, let me know if the question is not clear I will give you some drawings to elaborate more.

Thanks!

We would also appreciate this.

It would be ideal to differentiate between a participant becoming disconnected if:

  • evicted due to room being completed
  • network factors have dropped the connection
  • made a user action to leave the room (e.g. clicking a button)

Hey @markandrus is there any hope of getting this more granular reporting?

Yes, @jamesgraham — the feature request on the backend is tagged VIDEO-1550. We will provision a distinct error code in the 531XX block, "Room errors". For example, it might be "Room completed". Then, if you were to be disconnected from the Room due to completion, you'd unambiguously know what happened.

@jamesgraham let me also clarify:

  • 1.9.0 will fix some bugs where the "disconnected" event does _not_ include an error, even when the Room was disconnected in error.
  • Once we do that, only intentional disconnects, e.g. due to calling disconnect, will emit the "disconnected" event _without_ an error.

Thanks, we look forward to 1.9.0 and any updated docs 🎉

Reopening until we actually do the release.

This was released in twilio-video.[email protected].

Was this page helpful?
0 / 5 - 0 ratings