100ms Logo

100ms

Docs

Search docs
/

Remove Peer

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

Check if user has permissions

const removeOthers: boolean = peer.role.permissions.removeOthers;

Remove Peer

import { HMSPeer } from '@100mslive/react-native-hms'; const reason = 'removed from room'; // instance acquired from build() method const peer: HMSPeer = hmsInstance?.remotePeers[0] await hmsInstance.removePeer(peer, reason) .then(d => console.log('Remove Peer Success: ', d)) .catch(e => console.log('Remove Peer Error: ', e));

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.

// import classes import { HMSUpdateListenerActions, HMSLeaveRoomRequest } from '@100mslive/react-native-hms'; const onRemovedFromRoom = (data: HMSLeaveRoomRequest) => { // redirect to home screen }; hmsInstance.addEventListener(HMSUpdateListenerActions.ON_REMOVED_FROM_ROOM, onRemovedFromRoom);