Skip to main content
Version: 4.x.x

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 Participant object as parameter.

onParticipantLeft​

  • This event is triggered when someone leaves the room.
  • It passes the Participant who left and a reason, a LeaveReason that tells why they left. Read reason.message for a description.

onWebcamRequested​

  • This event will be triggered to the participant B when any other participant A requests to enable webcam of participant B.
  • On accepting the request, webcam of participant B will be enabled.

onMicRequested​

  • This event will be triggered to the participant B when any other participant A requests to enable mic of participant B.
  • On accepting the request, mic of participant B will be enabled.

Example​

Here is the usage of all the events mentioned in this page.

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