/** * Events are the primary way LiveKit notifies your application of changes. * * The following are events emitted by [[Room]], listen to room events like * * ```typescript * room.on(RoomEvent.TrackPublished, (track, publication, participant) => {}) * ``` */ export enum RoomEvent { /** * When the connection to the server has been established */ Connected = 'connected', /** * When the connection to the server has been interrupted and it's attempting * to reconnect. */ Reconnecting = 'reconnecting', /** * When the signal connection to the server has been interrupted. This isn't noticeable to users most of the time. * It will resolve with a `RoomEvent.Reconnected` once the signal connection has been re-established. * If media fails additionally it an additional `RoomEvent.Reconnecting` will be emitted. */ SignalReconnecting = 'signalReconnecting', /** * Fires when a reconnection has been successful. */ Reconnected = 'reconnected', /** * When disconnected from room. This fires when room.disconnect() is called or * when an unrecoverable connection issue had occurred. * * DisconnectReason can be used to determine why the participant was disconnected. Notable reasons are * - DUPLICATE_IDENTITY: another client with the same identity has joined the room * - PARTICIPANT_REMOVED: participant was removed by RemoveParticipant API * - ROOM_DELETED: the room has ended via DeleteRoom API * * args: ([[DisconnectReason]]) */ Disconnected = 'disconnected', /** * Whenever the connection state of the room changes * * args: ([[ConnectionState]]) */ ConnectionStateChanged = 'connectionStateChanged', /** * When participant has been moved to a different room by the service request. * The behavior looks like the participant has been disconnected and reconnected to a different room * seamlessly without connection state transition. * A new token will be provided for reconnecting to the new room if needed. * * args: ([[room: string, token: string]]) */ Moved = 'moved', /** * When input or output devices on the machine have changed. */ MediaDevicesChanged = 'mediaDevicesChanged', /** * When a [[RemoteParticipant]] joins *after* the local * participant. It will not emit events for participants that are already * in the room * * args: ([[RemoteParticipant]]) */ ParticipantConnected = 'participantConnected', /** * When a [[RemoteParticipant]] leaves *after* the local * participant has joined. * * args: ([[RemoteParticipant]]) */ ParticipantDisconnected = 'participantDisconnected', /** * When a new track is published to room *after* the local * participant has joined. It will not fire for tracks that are already published. * * A track published doesn't mean the participant has subscribed to it. It's * simply reflecting the state of the room. * * args: ([[RemoteTrackPublication]], [[RemoteParticipant]]) */ TrackPublished = 'trackPublished', /** * The [[LocalParticipant]] has subscribed to a new track. This event will **always** * fire as long as new tracks are ready for use. * * args: ([[RemoteTrack]], [[RemoteTrackPublication]], [[RemoteParticipant]]) */ TrackSubscribed = 'trackSubscribed', /** * Could not subscribe to a track * * args: (track sid, [[RemoteParticipant]]) */ TrackSubscriptionFailed = 'trackSubscriptionFailed', /** * A [[RemoteParticipant]] has unpublished a track * * args: ([[RemoteTrackPublication]], [[RemoteParticipant]]) */ TrackUnpublished = 'trackUnpublished', /** * A subscribed track is no longer available. Clients should listen to this * event and ensure they detach tracks. * * args: ([[Track]], [[RemoteTrackPublication]], [[RemoteParticipant]]) */ TrackUnsubscribed = 'trackUnsubscribed', /** * A track that was muted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]] * * args: ([[TrackPublication]], [[Participant]]) */ TrackMuted = 'trackMuted', /** * A track that was unmuted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]] * * args: ([[TrackPublication]], [[Participant]]) */ TrackUnmuted = 'trackUnmuted', /** * A local track was published successfully. This event is helpful to know * when to update your local UI with the newly published track. * * args: ([[LocalTrackPublication]], [[LocalParticipant]]) */ LocalTrackPublished = 'localTrackPublished', /** * A local track was unpublished. This event is helpful to know when to remove * the local track from your UI. * * When a user stops sharing their screen by pressing "End" on the browser UI, * this event will also fire. * * args: ([[LocalTrackPublication]], [[LocalParticipant]]) */ LocalTrackUnpublished = 'localTrackUnpublished', /** * When a local audio track is published the SDK checks whether there is complete silence * on that track and emits the LocalAudioSilenceDetected event in that case. * This allows for applications to show UI informing users that they might have to * reset their audio hardware or check for proper device connectivity. */ LocalAudioSilenceDetected = 'localAudioSilenceDetected', /** * Active speakers changed. List of speakers are ordered by their audio level. * loudest speakers first. This will include the LocalParticipant too. * * Speaker updates are sent only to the publishing participant and their subscribers. * * args: (Array<[[Participant]]>) */ ActiveSpeakersChanged = 'activeSpeakersChanged', /** * Participant metadata is a simple way for app-specific state to be pushed to * all users. * When RoomService.UpdateParticipantMetadata is called to change a participant's * state, *all* participants in the room will fire this event. * * args: (prevMetadata: string, [[Participant]]) * */ ParticipantMetadataChanged = 'participantMetadataChanged', /** * Participant's display name changed * * args: (name: string, [[Participant]]) * */ ParticipantNameChanged = 'participantNameChanged', /** * Participant attributes is an app-specific key value state to be pushed to * all users. * When a participant's attributes changed, this event will be emitted with the changed attributes and the participant * args: (changedAttributes: [[Record