Skip to main content
Version: 4.x.x

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 roomState as 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 for onRoomJoined before you call Room methods.
    • RECONNECTING: The room is trying to reconnect after the connection was lost. Until it reconnects, most methods throw ERROR_ROOM_RECONNECTING.
    • DISCONNECTED: The room has been disconnected.
    • FAILED: The room failed to connect. This happens when join() fails, in which case join() 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 RoomEventListener protocol, and register the listener with the addEventListener(_:) method of the Room class.

Example​

Here is the usage of the event mentioned in this page.

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