Search code examples
twiliotwilio-video

Is there a way to subscribe to a room's `participantConnected` event without becoming a participant?


One can use the room returned from calling Video.connect to subscribe to a room's participantConnected event, so that all kinds of different logic can be executed when a new participant joins a room. I can also query rooms remotely without Video.connect to see how many participants are currently connected. However, I would like be able to use the participantConnected event to display in real time if someone is in a room, without actually joining the room.

Is this possible and how would I do that without becoming a participant via Video.connect and without polling twilio's api?

Preferably, I'd like to do this on the javascript side, but I could use twilio's api wrapper library on the server-side if I had to. I just want the client to get notified somehow when someone enters or leaves a room so I can display whether the room is empty in real time.


Solution

  • In order to receive those events with the client SDK, you would need to join the room as you would need a connection to it in order to receive events from it.

    You can, however, subscribe to status callback webhooks for rooms. There are lots of events that a room emits that can be received as webhooks, such as room-created, room-ended, and, as you've asked for, participant-connected.

    You can set the statusCallback when you create a room with the REST API and you can see all the parameters that are sent as part of the webhook request here.