1
votes

After I create a Twilio Video room, and connected ith several users, I would like to ask is it possible to force others once a selected user is disconneted?

For example, an admin is the owner of the room, and two other participants joined the room. If I want to set an additional disconnect event when the username with "admin" can push all other participants to leave the room. Is it possible to do this with Twilio?

2

2 Answers

1
votes

You can remove the participant from the Twilio room. All you have to do is, set the participant status as disconnected.

To remove a participant - Click here

Or use the following code,

var apiKeySid = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var apiKeySecret = 'your_api_key_secret';
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var Twilio = require('twilio');

var client = new Twilio(apiKeySid, apiKeySecret, {accountSid: accountSid});

client.video.rooms('RoomName or RoomSid')
  .participants('ParticipantName or Sid')
  .update({status: 'disconnected'})
  .then(participant => {
    console.log(participant.status);
  });

Note: It's only works, Only if the room status is 'connected'.

To check the room status.

Happy Coding!

0
votes

According to the response of Twilio, they do not have a api call to remove other user by the identity.

IF you want to remove other user, you are recommended to send a message to the target client, and ask them to leave the room by them themselves (you may use Twilio msg, or Pusher to broadcast the msg with tour own backend).

For your reference, if you want to close the room, just call Twilio api, and all the participants in that room will be forced to leave.