Delegate methods for participant events. Since Participant inherits from MulticastDelegate, you can call add(delegate:) on any Participant to register multiple delegates.
To ensure each participant’s delegate is registered, look through room.localParticipant and room.remoteParticipants on connect and register delegates on new participants inside RoomDelegate.room(_:participantDidConnect:).
Usage
class MyViewController: UIViewController, ParticipantDelegate {
func setupParticipant(_ participant: Participant) {
participant.add(delegate: self)
}
func participant(_ participant: Participant, didUpdateIsSpeaking isSpeaking: Bool) {
print("\(participant.name) is \(isSpeaking ? "speaking" : "silent")")
}
}
Participant Events
participant(_:didUpdateMetadata:)
Participant metadata has updated.Works for both LocalParticipant and RemoteParticipant.func participant(_ participant: Participant, didUpdateMetadata metadata: String?)
participant(_:didUpdateName:)
Participant name has updated.Works for both LocalParticipant and RemoteParticipant.func participant(_ participant: Participant, didUpdateName name: String)
participant(_:didUpdateIsSpeaking:)
The speaking status of a participant has changed.Works for both LocalParticipant and RemoteParticipant.func participant(_ participant: Participant, didUpdateIsSpeaking isSpeaking: Bool)
participant(_:didUpdateState:)
Participant state has updated.Works for both LocalParticipant and RemoteParticipant.func participant(_ participant: Participant, didUpdateState state: ParticipantState)
participant(_:didUpdateConnectionQuality:)
Connection quality of a participant has updated.Works for both LocalParticipant and RemoteParticipant.func participant(_ participant: Participant, didUpdateConnectionQuality connectionQuality: ConnectionQuality)
participant(_:didUpdatePermissions:)
Participant permissions have updated.func participant(_ participant: Participant, didUpdatePermissions permissions: ParticipantPermissions)
participant(_:didUpdateAttributes:)
Participant attributes have updated.func participant(_ participant: Participant, didUpdateAttributes attributes: [String: String])
Track Publication Events
participant(_:trackPublication:didUpdateIsMuted:)
Muted state has updated for a track publication.For LocalParticipant, this is called when setMute is called on LocalTrackPublication, or if the server has requested the participant to be muted.func participant(_ participant: Participant, trackPublication: TrackPublication, didUpdateIsMuted isMuted: Bool)
participant(_:trackPublication:didReceiveTranscriptionSegments:)
Received transcription segments for a track.func participant(_ participant: Participant, trackPublication: TrackPublication, didReceiveTranscriptionSegments segments: [TranscriptionSegment])
Local Participant Events
participant(_:didPublishTrack:)
The local participant has published a track.func participant(_ participant: LocalParticipant, didPublishTrack publication: LocalTrackPublication)
participant(_:didUnpublishTrack:)
The local participant has unpublished a track.func participant(_ participant: LocalParticipant, didUnpublishTrack publication: LocalTrackPublication)
participant(_:remoteDidSubscribeTrack:)
Fired when the first remote participant has subscribed to the local participant’s track.func participant(_ participant: LocalParticipant, remoteDidSubscribeTrack publication: LocalTrackPublication)
participant(_:didMoveToRoomNamed:)
The local participant was moved to a different room.func participant(_ participant: LocalParticipant, didMoveToRoomNamed roomName: String)
Remote Participant Events
participant(_:didPublishTrack:)
A new remote track publication was published to the room after the local participant has joined.This delegate method will not be called for tracks that are already published when you join.
func participant(_ participant: RemoteParticipant, didPublishTrack publication: RemoteTrackPublication)
participant(_:didUnpublishTrack:)
The remote participant has unpublished a track.func participant(_ participant: RemoteParticipant, didUnpublishTrack publication: RemoteTrackPublication)
participant(_:didSubscribeTrack:)
The local participant has subscribed to a new remote track.This event will always fire as long as new tracks are ready for use.func participant(_ participant: RemoteParticipant, didSubscribeTrack publication: RemoteTrackPublication)
participant(_:didUnsubscribeTrack:)
Unsubscribed from a remote track publication and it is no longer available.Clients should listen to this event and handle cleanup.func participant(_ participant: RemoteParticipant, didUnsubscribeTrack publication: RemoteTrackPublication)
participant(_:didFailToSubscribeTrackWithSid:error:)
Could not subscribe to a track.This is an error state; the subscription can be retried.func participant(_ participant: RemoteParticipant, didFailToSubscribeTrackWithSid trackSid: Track.Sid, error: LiveKitError)
participant(_:trackPublication:didUpdateStreamState:)
Stream state has updated for a remote track publication.func participant(_ participant: RemoteParticipant, trackPublication: RemoteTrackPublication, didUpdateStreamState streamState: StreamState)
participant(_:trackPublication:didUpdateIsSubscriptionAllowed:)
Subscription permission has updated for a remote track publication.func participant(_ participant: RemoteParticipant, trackPublication: RemoteTrackPublication, didUpdateIsSubscriptionAllowed isSubscriptionAllowed: Bool)
Data Events
participant(_:didReceiveData:forTopic:encryptionType:)
Data was received from a remote participant.func participant(_ participant: RemoteParticipant, didReceiveData data: Data, forTopic topic: String, encryptionType: EncryptionType)