Hierarchy (view full)

Properties

audioLevel: number = 0

audio level between 0-1.0, 1 being loudest, 0 being softest

audioTrackPublications: Map<string, LocalTrackPublication>
identity: string

client assigned identity, encoded in JWT token

isSpeaking: boolean = false

if participant is currently speaking

lastSpokeAt?: Date
metadata?: string

client metadata, opaque to livekit

name?: string

client assigned display name, encoded in JWT token

permissions?: ParticipantPermission
sid: string

server assigned unique id

trackPublications: Map<string, LocalTrackPublication>

map of track sid => all published tracks

videoTrackPublications: Map<string, LocalTrackPublication>

Accessors

  • get attributes(): Readonly<Record<string, string>>
  • participant attributes, similar to metadata, but as a key/value map

    Returns Readonly<Record<string, string>>

Methods

  • Parameters

    Returns Promise<{
        editTimestamp: number;
        id: string;
        message: string;
        timestamp: number;
    }>

  • Publish both camera and microphone at the same time. This is useful for displaying a single Permission Dialog box to the end user.

    Returns Promise<void>

  • Publish a new data payload to the room. Data will be forwarded to each participant in the room if the destination field in publishOptions is empty

    Parameters

    • data: Uint8Array

      Uint8Array of the payload. To send string data, use TextEncoder.encode

    • options: DataPublishOptions = {}

      optionally specify a reliable, topic and destination

    Returns Promise<void>

  • Establishes the participant as a receiver for calls of the specified RPC method. Will overwrite any existing callback for the same method.

    Parameters

    • method: string

      The name of the indicated RPC method

    • handler: ((data: RpcInvocationData) => Promise<string>)

      Will be invoked when an RPC request for this method is received

    Returns void

    A promise that resolves when the method is successfully registered

    room.localParticipant?.registerRpcMethod(
    'greet',
    async (data: RpcInvocationData) => {
    console.log(`Received greeting from ${data.callerIdentity}: ${data.payload}`);
    return `Hello, ${data.callerIdentity}!`;
    }
    );

    The handler should return a Promise that resolves to a string. If unable to respond within responseTimeout, the request will result in an error on the caller's side.

    You may throw errors of type RpcError with a string message in the handler, and they will be received on the caller's side with the message intact. Other errors thrown in your handler will not be transmitted as-is, and will instead arrive to the caller as 1500 ("Application Error").

  • Set or update participant attributes. It will make updates only to keys that are present in attributes, and will not override others. Note: this requires canUpdateOwnMetadata permission.

    Parameters

    • attributes: Record<string, string>

      attributes to update

    Returns Promise<void>

  • Sets and updates the metadata of the local participant. Note: this requires canUpdateOwnMetadata permission. method will throw if the user doesn't have the required permissions

    Parameters

    • metadata: string

    Returns Promise<void>

  • Sets and updates the name of the local participant. Note: this requires canUpdateOwnMetadata permission. method will throw if the user doesn't have the required permissions

    Parameters

    • name: string

    Returns Promise<void>

  • Control who can subscribe to LocalParticipant's published tracks.

    By default, all participants can subscribe. This allows fine-grained control over who is able to subscribe at a participant and track level.

    Note: if access is given at a track-level (i.e. both [allParticipantsAllowed] and [ParticipantTrackPermission.allTracksAllowed] are false), any newer published tracks will not grant permissions to any participants and will require a subsequent permissions update to allow subscription.

    Parameters

    • allParticipantsAllowed: boolean

      Allows all participants to subscribe all tracks. Takes precedence over [[participantTrackPermissions]] if set to true. By default this is set to true.

    • participantTrackPermissions: ParticipantTrackPermission[] = []

      Full list of individual permissions per participant/track. Any omitted participants will not receive any permissions.

    Returns void