@livekit/rtc-node
    Preparing search index...

    Class LocalParticipant

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    ffi_handle: FfiHandle
    info: ParticipantInfo
    trackPublications: Map<string, LocalTrackPublication> = ...

    Accessors

    Methods

    • Internal

      Parameters

      • invocationId: bigint
      • method: string
      • requestId: string
      • callerIdentity: string
      • payload: string
      • responseTimeout: number

      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}!`;
      }
      );

      See RpcInvocationData for more details on invocation params.

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

    • Sends a chat message to participants in the room

      Parameters

      • text: string

        The text content of the chat message.

      • OptionaldestinationIdentities: string[]

        An optional array of recipient identities to whom the message will be sent. If omitted, the message is broadcast to all participants.

      • OptionalsenderIdentity: string

        An optional identity of the sender. If omitted, the default sender identity is used.

      Returns Promise<ChatMessage>

    • Parameters

      • text: string
      • Optionaloptions: {
            attributes?: Record<string, string>;
            destinationIdentities?: string[];
            streamId?: string;
            topic?: string;
        }

      Returns Promise<BaseStreamInfo>

    • Parameters

      • Optionaloptions: {
            attributes?: Record<string, string>;
            destinationIdentities?: string[];
            mimeType?: string;
            name?: string;
            streamId?: string;
            topic?: string;
            totalSize?: number;
        }

      Returns Promise<ByteStreamWriter>

    • Returns a StreamWriter instance that allows to write individual chunks of text to a stream. Well suited for TTS and/or streaming LLM output. If you want to simply send a text then use sendText() instead

      Parameters

      • Optionaloptions: {
            attributes?: Record<string, string>;
            destinationIdentities?: string[];
            senderIdentity?: string;
            streamId?: string;
            topic?: string;
        }

      Returns Promise<TextStreamWriter>

    • Unregisters a previously registered RPC method.

      Parameters

      • method: string

        The name of the RPC method to unregister

      Returns void