LiveKit JS Client SDK - v2.25.0
    Preparing search index...

    Class LocalParticipantExperimental

    Methods the dataStreams extension adds to the local participant.

    Hierarchy (View Summary)

    Index
    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
    registerRpcMethod: (
        method: string,
        handler: (data: RpcInvocationData) => Promise<string>,
    ) => void

    Type Declaration

      • (method: string, handler: (data: RpcInvocationData) => Promise<string>): void
      • Establishes the participant as a receiver for calls of the specified RPC 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

        If a handler for this method is already registered (must call unregisterRpcMethod first)

        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").

    use room.registerRpcMethod instead

    sid: string

    server assigned unique id

    trackPublications: Map<string, LocalTrackPublication>

    map of track sid => all published tracks

    unregisterRpcMethod: (method: string) => void

    Type Declaration

      • (method: string): void
      • Unregisters a previously registered RPC method.

        Parameters

        • method: string

          The name of the RPC method to unregister

        Returns void

    use room.unregisterRpcMethod instead

    videoTrackPublications: Map<string, LocalTrackPublication>
    • get attributes(): Readonly<Record<string, string>>

      participant attributes, similar to metadata, but as a key/value map

      Returns Readonly<Record<string, string>>

    • 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>

    • Publish SIP DTMF message to the room.

      Parameters

      • code: number

        DTMF code

      • digit: string

        DTMF digit

      Returns Promise<void>

    • Sends the given bytes to participants in the room via the data channel. For files, consider using sendFile; for longer/incremental payloads, streamBytes.

      Parameters

      • bytes: Uint8Array

        The byte payload

      • Optionaloptions: SendBytesOptions
        • Optionalattributes?: Record<string, string>
        • Optionalcompress?: boolean

          Whether to compress the payload (deflate-raw). Defaults to true. Compression is only applied when every recipient supports data streams v2 and the runtime can compress.

        • OptionaldestinationIdentities?: string[]
        • OptionalmimeType?: string
        • Optionalname?: string
        • OptionalonProgress?: (progress: number) => void
        • Optionaltopic?: string

      Returns Promise<ByteStreamInfo>

    • Send a File to all participants in the room via the data channel.

      Parameters

      • file: File

        The File object payload

      • Optionaloptions: SendFileOptions
        • topic

          Topic identifier used to route the stream to appropriate handlers.

        • onProgress

          A callback function used to monitor the upload progress percentage.

      Returns Promise<{ id: string }>

    • Sends the given string to participants in the room via the data channel. For longer messages, consider using streamText instead.

      Parameters

      • text: string

        The text payload

      • Optionaloptions: SendTextOptions
        • Optionalattachments?: File[]
        • Optionalattributes?: Record<string, string>
        • Optionalcompress?: boolean

          Whether to compress the payload (deflate-raw). Defaults to true. Compression is only applied when every recipient supports data streams v2 and the runtime can compress.

        • OptionaldestinationIdentities?: string[]
        • OptionalonProgress?: (progress: number) => void
        • Optionaltopic?: string

      Returns Promise<TextStreamInfo>

    • 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