Participant Events - React Native
VideoSDK provides multiple types of events which can be listened to know about the participants in the room.
Here are the events specifically related to the participant:
onParticipantJoined()
- This event is triggered when someone joins the room, returning the
Participantobject as parameter. - It can be subscribed to using the
useRoomhook.
onParticipantLeft()
- This event is triggered when a participant leaves the room, returning the
Participantobject and a reason. You can refer to the reason details here - It can be subscribed to using the
useRoomhook.
onWebcamRequested()
- This event is triggered for participant
B, when another participant,Arequests to enable their webcam. - It passes the
participantIdof participantA, andaccept()andreject().accept()turns participantB's webcam on.reject()declines the request. - It can be subscribed to using the
useRoomhook.
onMicRequested()
- This event is triggered for participant
B, when another participant,Arequests to enable their mic. - It passes the
participantIdof participantA, andaccept()andreject().accept()turns participantB's mic on.reject()declines the request. - It can be subscribed to using the
useRoomhook.
Example
Here is an example demonstrating the usage of all the events mentioned on this page.
function onMicRequested({ participantId, accept, reject }) {
// participantId is the participant who asked to enable your mic
accept(); // or reject()
}
function onWebcamRequested({ participantId, accept, reject }) {
// participantId is the participant who asked to enable your webcam
accept(); // or reject()
}
function onParticipantJoined(participant) {
console.log(" onParticipantJoined", participant);
}
function onParticipantLeft(participant,reason) {
console.log(`Participant "${participant.displayName}" left the room. Reason: ${reason.message} (Code: ${reason.code})`);
}
useRoom({
onParticipantJoined,
onParticipantLeft,
onMicRequested,
onWebcamRequested,
});
API Reference
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord

