Skip to main content
The RoomDelegate protocol receives room events as well as participant events.
The thread which the delegate will be called on is not guaranteed to be the main thread. If you will perform any UI update from the delegate, ensure the execution is from the main thread.

Usage

class MyViewController: UIViewController, RoomDelegate {
    func setupRoom() {
        let room = Room()
        room.add(delegate: self)
    }
    
    func room(_ room: Room, localParticipant: LocalParticipant, didPublish publication: LocalTrackPublication) {
        DispatchQueue.main.async {
            // Update UI on main thread
            self.localVideoView.isHidden = false
        }
    }
}

Connection Events

room(_:didUpdateConnectionState:from:)
optional
Called when the room’s connection state has updated.
This method is not called for ReconnectMode.quick. Use room(_:didStartReconnectWithMode:) and room(_:didCompleteReconnectWithMode:) instead.
func room(_ room: Room, didUpdateConnectionState connectionState: ConnectionState, from oldConnectionState: ConnectionState)
roomDidConnect(_:)
optional
Successfully connected to the room.
func roomDidConnect(_ room: Room)
roomIsReconnecting(_:)
optional
Previously connected to room but re-attempting to connect due to network issues.
Not called for ReconnectMode.quick.
func roomIsReconnecting(_ room: Room)
roomDidReconnect(_:)
optional
Successfully re-connected to the room.
Not called for ReconnectMode.quick.
func roomDidReconnect(_ room: Room)
room(_:didStartReconnectWithMode:)
optional
Reconnection started with the specified mode.
func room(_ room: Room, didStartReconnectWithMode reconnectMode: ReconnectMode)
room(_:didCompleteReconnectWithMode:)
optional
Reconnection completed successfully.
func room(_ room: Room, didCompleteReconnectWithMode reconnectMode: ReconnectMode)
room(_:didUpdateReconnectMode:)
optional
Room reconnect mode has updated.
func room(_ room: Room, didUpdateReconnectMode reconnectMode: ReconnectMode)
room(_:didFailToConnectWithError:)
optional
Could not connect to the room. Only triggered when the initial connect attempt fails.
func room(_ room: Room, didFailToConnectWithError error: LiveKitError?)
room(_:didDisconnectWithError:)
optional
Client disconnected from the room unexpectedly after a successful connection.
func room(_ room: Room, didDisconnectWithError error: LiveKitError?)

Room State Updates

room(_:didUpdateMetadata:)
optional
Room metadata has updated.
func room(_ room: Room, didUpdateMetadata metadata: String?)
room(_:didUpdateIsRecording:)
optional
Room recording state has updated.
func room(_ room: Room, didUpdateIsRecording isRecording: Bool)
room(_:didMoveToRoomNamed:)
optional
The local participant was moved to a different room.
func room(_ room: Room, didMoveToRoomNamed roomName: String)

Participant Management

room(_:participantDidConnect:)
optional
A remote participant joined the room.
func room(_ room: Room, participantDidConnect participant: RemoteParticipant)
room(_:participantDidDisconnect:)
optional
A remote participant left the room.
func room(_ room: Room, participantDidDisconnect participant: RemoteParticipant)
room(_:didUpdateSpeakingParticipants:)
optional
Active speakers in the room have updated.
func room(_ room: Room, didUpdateSpeakingParticipants participants: [Participant])
room(_:participant:didUpdateMetadata:)
optional
Participant metadata has updated.
func room(_ room: Room, participant: Participant, didUpdateMetadata metadata: String?)
room(_:participant:didUpdateName:)
optional
Participant name has updated.
func room(_ room: Room, participant: Participant, didUpdateName name: String)
room(_:participant:didUpdateState:)
optional
Participant state has updated.
func room(_ room: Room, participant: Participant, didUpdateState state: ParticipantState)
room(_:participant:didUpdateConnectionQuality:)
optional
Participant connection quality has updated.
func room(_ room: Room, participant: Participant, didUpdateConnectionQuality quality: ConnectionQuality)
room(_:participant:didUpdatePermissions:)
optional
Participant permissions have updated.
func room(_ room: Room, participant: Participant, didUpdatePermissions permissions: ParticipantPermissions)
room(_:participant:didUpdateAttributes:)
optional
Participant attributes have updated.
func room(_ room: Room, participant: Participant, didUpdateAttributes attributes: [String: String])

Track Publications

room(_:participant:didPublishTrack:)
optional
A participant has published a track.Available for both local and remote participants.
func room(_ room: Room, participant: LocalParticipant, didPublishTrack publication: LocalTrackPublication)
func room(_ room: Room, participant: RemoteParticipant, didPublishTrack publication: RemoteTrackPublication)
room(_:participant:didUnpublishTrack:)
optional
A participant has unpublished a track.Available for both local and remote participants.
func room(_ room: Room, participant: LocalParticipant, didUnpublishTrack publication: LocalTrackPublication)
func room(_ room: Room, participant: RemoteParticipant, didUnpublishTrack publication: RemoteTrackPublication)
room(_:participant:remoteDidSubscribeTrack:)
optional
Fired when the first remote participant has subscribed to the local participant’s track.
func room(_ room: Room, participant: LocalParticipant, remoteDidSubscribeTrack publication: LocalTrackPublication)
room(_:participant:didSubscribeTrack:)
optional
The local participant subscribed to a remote track.
func room(_ room: Room, participant: RemoteParticipant, didSubscribeTrack publication: RemoteTrackPublication)
room(_:participant:didUnsubscribeTrack:)
optional
The local participant unsubscribed from a remote track.
func room(_ room: Room, participant: RemoteParticipant, didUnsubscribeTrack publication: RemoteTrackPublication)
room(_:participant:didFailToSubscribeTrackWithSid:error:)
optional
Failed to subscribe to a track.
func room(_ room: Room, participant: RemoteParticipant, didFailToSubscribeTrackWithSid trackSid: Track.Sid, error: LiveKitError)
room(_:participant:trackPublication:didUpdateIsMuted:)
optional
Track muted state has updated.
func room(_ room: Room, participant: Participant, trackPublication: TrackPublication, didUpdateIsMuted isMuted: Bool)
room(_:participant:trackPublication:didUpdateStreamState:)
optional
Track stream state has updated.
func room(_ room: Room, participant: RemoteParticipant, trackPublication: RemoteTrackPublication, didUpdateStreamState streamState: StreamState)

Data and Encryption

room(_:participant:didReceiveData:forTopic:encryptionType:)
optional
Received data from a remote participant or server.participant will be nil if the data was broadcast from the server.
func room(_ room: Room, participant: RemoteParticipant?, didReceiveData data: Data, forTopic topic: String, encryptionType: EncryptionType)
room(_:didFailToDecryptDataWithEror:)
optional
Failed to decrypt a data packet when encryption is enabled.
func room(_ room: Room, didFailToDecryptDataWithEror error: LiveKitError)
room(_:trackPublication:didUpdateE2EEState:)
optional
End-to-end encryption state for a track has updated.
func room(_ room: Room, trackPublication: TrackPublication, didUpdateE2EEState state: E2EEState)
room(_:participant:trackPublication:didReceiveTranscriptionSegments:)
optional
Received transcription segments for a track.
func room(_ room: Room, participant: Participant, trackPublication: TrackPublication, didReceiveTranscriptionSegments segments: [TranscriptionSegment])

Build docs developers (and LLMs) love