Removing Participant's during Conference

subhra_saranyu

New Member
Hi, Max, We are planning on creating a functionality where a meeting host should be able to remove a participant or Mute them forcefully if requires, is there any way to do that ?
 

Max

Administrator
Staff member
Good day.
Using RoomApi, you can send a custom message to participant, for example
Code:
var participants = room.getParticipants();
for (var i = 0; i < participants.length; i++) {
     if(participants[i].name == "Alice") {
           // Send a message to kick user Alice
           var message = base64_encode('CUSTOM_{"action":"kick"}');
           participants[i].sendMessage(message);
           break;
     }
}
Please note that message contents should be serialized to text by some way.
Then the participant receives the message and leaves the conference
Code:
    connection.join({name: getRoomName(), record: isRecord()}).on(ROOM_EVENT.STATE, function(room){
        ...
    }).on(ROOM_EVENT.MESSAGE, function(message){
        var custom = base64_decode(message);
        if(custom.CUSTOM_) {
              // Custom message
              if(custom.CUSTOM_.action == "kick") {
                    // Leave the room
                    room.leave().then(onLeft, onLeft);
              }
        } else {
              // Usual text message
              addMessage(message.from.name(), message.text);
        }
    });
Note that custom message should be deserialized on receiving
 

subhra_saranyu

New Member
Hi, Max I am getting undefined while using the above method, any idea on that ?

PS: I am getting correct participant's name but somehow messages are not coming in the ROOM EVENT itself, any specific reason for the same ?
 

Max

Administrator
Staff member
Hi, Max I am getting undefined while using the above method, any idea on that ?
The example above is a sample how to implement, not a working code. So please provide your code to check or access to webpage to test using this form.
PS: I am getting correct participant's name but somehow messages are not coming in the ROOM EVENT itself, any specific reason for the same ?
Please test in the Conference example. Are there any text messages loss? If not, seems like the problem is in your code.
 
Top