Room Events - iOS
VideoSDK provides events that tell you the current state of 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 room.
onRoomJoined
- This event is triggered when the room is successfully joined.
- It can be triggered again when the SDK rejoins the room after the connection was lost, so make the work you do here safe to repeat.
onRoomLeft
- This event is triggered when the room is left.
- It passes
reason, aLeaveReasonthat tells why the local participant left, for example.MANUAL_LEAVE_CALLED. Readreason.messagefor a description.
onSpeakerChanged
- This event is triggered when the active speaker in the room gets changed.
- It passes
activeSpeakerId, the ID of the participant who is speaking, ornilwhen no one is speaking.
Example
Here is the usage of all the events mentioned in this page.
- Swift
extension RoomViewController: RoomEventListener {
/// Room joined
func onRoomJoined() {
print("Room Joined")
}
/// Room left, with the reason
func onRoomLeft(reason: LeaveReason) {
print("Room Left:", reason.message)
}
/// Speaker changed
func onSpeakerChanged(activeSpeakerId: String?) {
print("Speaker changed to:", activeSpeakerId ?? "")
}
}
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

