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

    Interface CoreRoomExperimental

    The room without optional features. Use CoreRoom.with(...extensions) to build a room class with the features an application needs, or use Room from the main entry for all of them.

    In LiveKit, a room is the logical grouping for a list of participants. Participants in a room can publish tracks, and subscribe to others' tracks.

    a Room fires [[RoomEvent | RoomEvents]].

    interface CoreRoom {
        activeSpeakers: Participant[];
        bufferedSegments: Map<string, TranscriptionSegment>;
        isE2EEEnabled: boolean;
        localParticipant: LocalParticipant;
        options: InternalRoomOptions;
        remoteParticipants: Map<string, RemoteParticipant>;
        serverInfo?: Partial<ServerInfo>;
        state: ConnectionState;
        get canPlaybackAudio(): boolean;
        get canPlaybackVideo(): boolean;
        get hasE2EESetup(): boolean;
        get isRecording(): boolean;
        get metadata(): string | undefined;
        get name(): string;
        get numParticipants(): number;
        get numPublishers(): number;
        connect(
            url: string,
            token: string,
            opts?: RoomConnectOptions,
        ): Promise<void>;
        disconnect(stopTracks?: boolean): Promise<void>;
        dispose(): Promise<void>;
        emit<E extends keyof RoomEventCallbacks>(
            event: E,
            ...args: Parameters<RoomEventCallbacks[E]>,
        ): boolean;
        getActiveDevice(kind: MediaDeviceKind): string | undefined;
        getParticipantByIdentity(identity: string): Participant | undefined;
        getSid(): TypedPromise<string, UnexpectedConnectionState>;
        prepareConnection(url: string, token?: string): Promise<void>;
        registerByteStreamHandler(topic: string, callback: ByteStreamHandler): void;
        registerRpcMethod(
            method: string,
            handler: (data: RpcInvocationData) => Promise<string>,
        ): void;
        registerTextStreamHandler(topic: string, callback: TextStreamHandler): void;
        setE2EEEnabled(enabled: boolean): Promise<void>;
        simulateParticipants(options: SimulationOptions): Promise<void>;
        startAudio(): Promise<void>;
        startVideo(): Promise<void>;
        switchActiveDevice(
            kind: MediaDeviceKind,
            deviceId: string,
            exact?: boolean,
        ): Promise<boolean>;
        unregisterByteStreamHandler(topic: string): void;
        unregisterRpcMethod(method: string): void;
        unregisterTextStreamHandler(topic: string): void;
    }

    Hierarchy (View Summary)

    Index
    activeSpeakers: Participant[] = []

    list of participants that are actively speaking. when this changes a [[RoomEvent.ActiveSpeakersChanged]] event is fired

    bufferedSegments: Map<string, TranscriptionSegment> = ...
    isE2EEEnabled: boolean = false

    reflects the sender encryption status of the local participant

    localParticipant: LocalParticipant

    the current participant

    options of room

    remoteParticipants: Map<string, RemoteParticipant>

    map of identity: [[RemoteParticipant]]

    serverInfo?: Partial<ServerInfo>
    state: ConnectionState = ConnectionState.Disconnected
    • get canPlaybackAudio(): boolean
      Experimental

      Returns true if audio playback is enabled

      Returns boolean

    • get canPlaybackVideo(): boolean
      Experimental

      Returns true if video playback is enabled

      Returns boolean

    • get isRecording(): boolean
      Experimental

      if the current room has a participant with recorder: true in its JWT grant

      Returns boolean

    • get metadata(): string | undefined
      Experimental

      room metadata

      Returns string | undefined

    • get name(): string
      Experimental

      user assigned name, derived from JWT token

      Returns string

    • Experimental

      disconnects the room, emits [[RoomEvent.Disconnected]]

      Parameters

      • stopTracks: boolean = true

      Returns Promise<void>

    • Experimental

      Releases everything the room holds: disconnects if connected, disposes the extensions and removes global listeners. The room cannot connect again afterwards.

      Returns Promise<void>

    • Experimental

      Parameters

      • kind: MediaDeviceKind

      Returns string | undefined

    • Experimental

      prepareConnection should be called as soon as the page is loaded, in order to speed up the connection attempt. This function will

      • perform DNS resolution and pre-warm the DNS cache
      • establish TLS connection and cache TLS keys

      With LiveKit Cloud, it will also determine the best edge data center for the current client to connect to if a token is provided.

      Parameters

      • url: string
      • Optionaltoken: string

      Returns Promise<void>

    • Experimental

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

    • Experimental

      Allows to populate a room with simulated participants. No actual connection to a server will be established, all state is

      Parameters

      • options: SimulationOptions

      Returns Promise<void>

    • Experimental

      Browsers have different policies regarding audio playback. Most requiring some form of user interaction (click/tap/etc). In those cases, audio will be silent until a click/tap triggering one of the following

      • startAudio
      • getUserMedia

      Returns Promise<void>

    • Experimental

      Switches all active devices used in this room to the given device.

      Note: setting AudioOutput is not supported on some browsers. See setSinkId

      Parameters

      • kind: MediaDeviceKind

        use videoinput for camera track, audioinput for microphone track, audiooutput to set speaker for all incoming audio tracks

      • deviceId: string
      • exact: boolean = true

      Returns Promise<boolean>

    • Experimental

      Unregisters a previously registered RPC method.

      Parameters

      • method: string

        The name of the RPC method to unregister

      Returns void