Remove Peer

If the local peer has removeOthers permission they can remove a peer using the below api.

try { const reason = 'Good Bye'; await hmsActions.removePeer(peer.id, reason); } catch (error) { // Permission denied or invalid peer ID or not connected to room console.error(error); }

🚧 If the local peer doesn't have the required removeOthers permission, a HMSException will be thrown.

Remove Peer Notification

Once the peer with adequate permissions calls removePeer for the local peer, the local peer will receive a notification with type REMOVED_FROM_ROOM with a HMSLeaveRoomRequest object as the data.

The SDK automatically calls leave and performs necessary clean ups immediately after this notification is sent, clients should show the appropriate UI(show a dialog, redirect to a 'good-bye' page) on receiving this notification.

hmsNotifications.onNotification((notification) => { if (!notification) { return; } switch (notification.type) { // ...Other notification type cases case 'REMOVED_FROM_ROOM': // Redirect or Show toast to user toast('Reason: ', notification.data.reason); break; } });

Have a suggestion? Recommend changes ->

Was this helpful?

1234