LiveKit Swift Client SDK Documentation

Protocol Room​Delegate​Obj​C

@objc
public protocol RoomDelegateObjC: AnyObject  

RoomDelegate receives room events as well as Participant events.

Important: The thread which the delegate will be called on, is not guranteed to be the main thread. If you will perform any UI update from the delegate, ensure the execution is from the main thread.

Example usage

func room(_ room: Room, localParticipant: LocalParticipant, didPublish publication: LocalTrackPublication) {
  DispatchQueue.main.async {
    // update UI here
    self.localVideoView.isHidden = false
  }
}

See the source code of Swift Example App for more examples.

%281 RoomDelegateObjC RoomDelegateObjC AnyObject AnyObject RoomDelegateObjC->AnyObject RoomDelegate RoomDelegate RoomDelegate->RoomDelegateObjC

Conforms To

AnyObject

Types Conforming to Room​Delegate​Obj​C

RoomDelegate

Optional Requirements

room(_:​did​Update:​old​Value:​)

@objc(room:didUpdateConnectionState:oldConnectionState:) optional
    func room(_ room: Room, didUpdate connectionState: ConnectionStateObjC, oldValue oldConnectionState: ConnectionStateObjC) 

room(_:​did​Connect:​)

@objc(room:didConnectIsReconnect:) optional
    func room(_ room: Room, didConnect isReconnect: Bool) 

Successfully connected to the room.

room(_:​did​Fail​ToConnect:​)

@objc(room:didFailToConnectWithError:) optional
    func room(_ room: Room, didFailToConnect error: Error) 

Could not connect to the room.

room(_:​did​Disconnect:​)

@objc(room:didDisconnectWithError:) optional
    func room(_ room: Room, didDisconnect error: Error?) 

Client disconnected from the room unexpectedly.

room(_:​participant​Did​Join:​)

@objc(room:participantDidJoin:) optional
    func room(_ room: Room, participantDidJoin participant: RemoteParticipant) 

When a RemoteParticipant joins after the LocalParticipant. It will not emit events for participants that are already in the room.

room(_:​participant​Did​Leave:​)

@objc(room:participantDidLeave:) optional
    func room(_ room: Room, participantDidLeave participant: RemoteParticipant) 

When a RemoteParticipant leaves after the LocalParticipant has joined.

room(_:​did​Update:​)

@objc(room:didUpdateSpeakers:) optional
    func room(_ room: Room, didUpdate speakers: [Participant]) 

Active speakers changed.

List of speakers are ordered by their Participant/audioLevel, loudest speakers first. This will include the LocalParticipant too.

room(_:​did​Update:​)

@objc(room:didUpdateMetadata:) optional
    func room(_ room: Room, didUpdate metadata: String?) 

Room's metadata has been updated.

room(_:​did​Update:​)

@objc(room:didUpdateIsRecording:) optional
    func room(_ room: Room, didUpdate isRecording: Bool) 

Room's recording state has been updated.

room(_:​participant:​did​Update:​)

@objc(room:participant:didUpdateMetadata:) optional
    func room(_ room: Room, participant: Participant, didUpdate metadata: String?) 

Same with ParticipantDelegate/participant(_:didUpdate:)-46iut.

room(_:​participant:​did​Update:​)

@objc(room:participant:didUpdateConnectionQuality:) optional
    func room(_ room: Room, participant: Participant, didUpdate connectionQuality: ConnectionQuality) 

Same with ParticipantDelegate/participant(_:didUpdate:)-7zxk1.

room(_:​participant:​did​Update:​muted:​)

@objc(room:participant:publication:didUpdateMuted:) optional
    func room(_ room: Room, participant: Participant, didUpdate publication: TrackPublication, muted: Bool) 

Same with ParticipantDelegate/participant(_:didUpdate:)-84m89.

room(_:​participant:​did​Update:​)

@objc(room:participant:didUpdatePermissions:) optional
    func room(_ room: Room, participant: Participant, didUpdate permissions: ParticipantPermissions) 

room(_:​participant:​did​Update:​stream​State:​)

@objc(room:participant:publication:didUpdateStreamState:) optional
    func room(_ room: Room, participant: RemoteParticipant, didUpdate publication: RemoteTrackPublication, streamState: StreamState) 

Same with ParticipantDelegate/participant(_:didUpdate:streamState:)-1lu8t.

room(_:​participant:​did​Publish:​)

@objc(room:participant:didPublishPublication:) optional
    func room(_ room: Room, participant: RemoteParticipant, didPublish publication: RemoteTrackPublication) 

Same with ParticipantDelegate/participant(_:didPublish:)-60en3.

room(_:​participant:​did​Unpublish:​)

@objc(room:participant:didUnpublishPublication:) optional
    func room(_ room: Room, participant: RemoteParticipant, didUnpublish publication: RemoteTrackPublication) 

Same with ParticipantDelegate/participant(_:didUnpublish:)-3bkga.

room(_:​participant:​did​Subscribe:​track:​)

@objc(room:participant:didSubscribePublication:track:) optional
    func room(_ room: Room, participant: RemoteParticipant, didSubscribe publication: RemoteTrackPublication, track: Track) 

Same with ParticipantDelegate/participant(_:didSubscribe:track:)-7mngl.

room(_:​participant:​did​Fail​ToSubscribe:​error:​)

@objc optional
    func room(_ room: Room, participant: RemoteParticipant, didFailToSubscribe trackSid: String, error: Error) 

Same with ParticipantDelegate/participant(_:didFailToSubscribe:error:)-10pn4.

room(_:​participant:​did​Unsubscribe:​track:​)

@objc(room:publication:didUnsubscribePublication:track:) optional
    func room(_ room: Room, participant: RemoteParticipant, didUnsubscribe publication: RemoteTrackPublication, track: Track) 

Same with ParticipantDelegate/participant(_:didUnsubscribe:track:)-3ksvp.

room(_:​participant:​did​Receive:​)

@objc(room:participant:didReceiveData:) optional
    func room(_ room: Room, participant: RemoteParticipant?, didReceive data: Data) 

Same with ParticipantDelegate/participant(_:didReceive:)-2t55a participant could be nil if data was sent by server api.

room(_:​local​Participant:​did​Publish:​)

@objc(room:localParticipant:didPublishPublication:) optional
    func room(_ room: Room, localParticipant: LocalParticipant, didPublish publication: LocalTrackPublication) 

Same with ParticipantDelegate/localParticipant(_:didPublish:)-90j2m.

room(_:​local​Participant:​did​Unpublish:​)

@objc(room:localParticipant:didUnpublishPublication:) optional
    func room(_ room: Room, localParticipant: LocalParticipant, didUnpublish publication: LocalTrackPublication) 

Same with ParticipantDelegate/participant(_:didUnpublish:)-3bkga.

room(_:​participant:​did​Update:​permission:​)

@objc optional
    func room(_ room: Room, participant: RemoteParticipant, didUpdate publication: RemoteTrackPublication, permission allowed: Bool) 

Same with ParticipantDelegate/participant(_:didUpdate:permission:).