Participant Events - iOS
VideoSDK provides events that tell you about the participants in the room.
You can implement all the methods of the RoomEventListener protocol and add the listener to the Room class using the addEventListener(_:) method of the Room class.
Here are the events which specifically relate to the participants.
onParticipantJoined
- This event is triggered when someone joins the room and returns the
Participantobject as parameter.
onParticipantLeft
- This event is triggered when someone leaves the room.
- It passes the
Participantwho left and areason, aLeaveReasonthat tells why they left. Readreason.messagefor a description.
onWebcamRequested
- This event will be triggered to the participant
Bwhen any other participantArequests to enable webcam of participantB. - On accepting the request, webcam of participant
Bwill be enabled.
onMicRequested
- This event will be triggered to the participant
Bwhen any other participantArequests to enable mic of participantB. - On accepting the request, mic of participant
Bwill be enabled.
Example
Here is the usage of all the events mentioned in this page.
- Swift
extension RoomViewController: RoomEventListener {
/// Participant joined
func onParticipantJoined(_ participant: Participant) {
print("ParticipantJoined", participant.displayName)
}
/// Participant left, with the reason
func onParticipantLeft(_ participant: Participant, reason: LeaveReason) {
print("onParticipantLeft", participant.displayName, reason.message)
}
/// Called when host requests to turn on the mic/audio
func onMicRequested(participantId: String?, accept: @escaping () -> Void, reject: @escaping () -> Void) {
// Ask the user, then call only one of the callbacks
// callback to accept the request
accept()
// or, callback to reject the request
// reject()
}
/// Called when host requests to turn on the camera/video
func onWebcamRequested(participantId: String?, accept: @escaping () -> Void, reject: @escaping () -> Void) {
// Ask the user, then call only one of the callbacks
// callback to accept the request
accept()
// or, callback to reject the request
// reject()
}
}
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

