Room Connection Events - iOS
VideoSDK provides onRoomStateChanged event which will notify you of the current connection state of the room.
onRoomStateChanged
- This event will be triggered when state of room changes.
- It will pass
roomStateas an event callback parameter which will indicate current state of the room.
All available states are :CONNECTING: The room is in the process of establishing a connection.CONNECTED: The room has successfully connected. When you join, wait foronRoomJoinedbefore you callRoommethods.RECONNECTING: The room is trying to reconnect after the connection was lost. Until it reconnects, most methods throwERROR_ROOM_RECONNECTING.DISCONNECTED: The room has been disconnected.FAILED: The room failed to connect. This happens whenjoin()fails, in which casejoin()also throws the error. It also happens when the SDK cannot reconnect after the connection was lost, and the local participant then leaves the room.
- To know when the local participant has left the room, use
onRoomLeft. - Implement this method of the
RoomEventListenerprotocol, and register the listener with theaddEventListener(_:)method of theRoomclass.
Example
Here is the usage of the event mentioned in this page.
- Swift
extension RoomViewController: RoomEventListener {
func onRoomStateChanged(roomState: RoomState) {
switch roomState {
case .CONNECTING:
print("Room is connecting")
case .CONNECTED:
print("Room is connected")
case .RECONNECTING:
print("Room is reconnecting")
case .DISCONNECTED:
print("Room is disconnected")
case .FAILED:
print("Room failed to connect")
@unknown default:
break
}
}
}
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

