@zoom/rtms
    Preparing search index...

    Class Client

    RTMS Client: Core interface for connecting to Zoom real-time media streams

    The Client class provides the main interface for connecting to and processing Zoom RTMS streams. Use this approach when you need to:

    • Connect to multiple meetings simultaneously
    • Process different media types (audio, video, transcript)
    • Handle session and user events
    import rtms from "@zoom/rtms";

    const client = new rtms.Client();

    // Set up event handlers
    client.onJoinConfirm((reason) => {
    console.log(`Join confirmed with reason: ${reason}`);
    });

    client.onAudioData((buffer, size, timestamp, metadata) => {
    console.log(`Received ${size} bytes of audio from ${metadata.userName}`);
    // Process audio data...
    });

    // Join the meeting
    client.join({
    meeting_uuid: "abc123-meeting-uuid",
    rtms_stream_id: "xyz789-stream-id",
    server_urls: "wss://rtms.zoom.us",
    pollInterval: 10 // milliseconds
    });

    // Later, leave the meeting
    client.leave();
    Index

    Constructors

    • Creates a new RTMS Client instance

      Each Client instance represents a connection to a single Zoom meeting. You can create multiple Client instances to connect to different meetings.

      Returns Client

    Methods

    • Joins a Zoom RTMS session with parameters object

      This method establishes a connection to a Zoom RTMS stream. After joining, callback methods will be invoked as events occur.

      Parameters

      • options: JoinParams

        An object containing join parameters

      Returns boolean

      true if the join operation succeeds

      client.join({
      meeting_uuid: "abc123-meeting-uuid",
      rtms_stream_id: "xyz789-stream-id",
      server_urls: "wss://rtms.zoom.us",
      pollInterval: 10
      });
    • Joins a Zoom RTMS session with individual parameters

      This method establishes a connection to a Zoom RTMS stream. After joining, callback methods will be invoked as events occur.

      Parameters

      • meetingUuid: string

        The UUID of the Zoom meeting

      • rtmsStreamId: string

        The RTMS stream ID for this connection

      • signature: string

        The authentication signature

      • serverUrls: string

        The server URL(s) to connect to

      • Optionaltimeout: number

        The timeout for the join operation in milliseconds

      Returns boolean

      true if the join operation succeeds

      // Generate signature
      const signature = rtms.generateSignature({
      client: "client_id",
      secret: "client_secret",
      uuid: "abc123-meeting-uuid",
      streamId: "xyz789-stream-id"
      });

      // Join with explicit parameters
      client.join(
      "abc123-meeting-uuid",
      "xyz789-stream-id",
      signature,
      "wss://rtms.zoom.us"
      );
    • Leaves the current session and releases resources

      This method disconnects from the Zoom RTMS stream, stops background polling, and releases resources.

      Returns boolean

      true if the leave operation succeeds

      // Leave the meeting when done
      client.leave();
    • Sets a callback for active speaker change events

      This automatically subscribes to EVENT_ACTIVE_SPEAKER_CHANGE.

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onActiveSpeakerEvent((timestamp, userId, userName) => {
      console.log(`Active speaker: ${userName} (${userId})`);
      });
    • Sets a callback for receiving audio data

      This callback is triggered when audio data is received from the meeting. It provides the raw audio data buffer and metadata about the sender.

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onAudioData((buffer, size, timestamp, metadata) => {
      console.log(`Received ${size} bytes of audio from ${metadata.userName}`);

      // Process the audio data
      // buffer - Raw audio data (Buffer)
      // size - Size of the audio data in bytes
      // timestamp - Timestamp of the audio data
      // metadata - Information about the sender
      });
    • Sets a callback for receiving deskshare data

      This callback is triggered when data is received from the meeting. It provides the raw audio data buffer and metadata about the sender.

      Parameters

      • callback: DeskshareDataCallback

        The callback function to invoke

      Returns boolean

      true if the callback was set successfully

      client.onDsData((buffer, size, timestamp, metadata) => {
      console.log(`Received ${size} bytes of deskshare data from ${metadata.userName}`);

      // Process the data
      // buffer - Raw deskshare data (Buffer)
      // size - Size of the deskshare data in bytes
      // timestamp - Timestamp of the deskshare data
      // metadata - Information about the sender
      });
    • Sets a callback for raw event data

      This provides access to the raw JSON event data from the SDK. Use this when you need custom event handling or access to all event types. This callback is called IN ADDITION to typed callbacks, not instead of.

      Parameters

      • callback: EventExCallback

        The callback function to invoke with raw JSON string

      Returns boolean

      true if the callback was set successfully

      client.onEventEx((eventData) => {
      const data = JSON.parse(eventData);
      console.log('Raw event:', data);
      });
    • Sets a callback for join confirmation events

      This callback is triggered when the join operation is confirmed by the server.

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onJoinConfirm((reason) => {
      console.log(`Join confirmed with reason code: ${reason}`);
      // 0 = success, other values indicate specific error conditions
      });
    • Sets a callback for leave events

      This callback is triggered when the client leaves the meeting, either voluntarily or due to an error.

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onLeave((reason) => {
      console.log(`Left meeting with reason code: ${reason}`);
      // Clean up resources or reconnect based on the reason code
      });
    • Sets a callback for media connection interrupted events

      This automatically subscribes to EVENT_MEDIA_CONNECTION_INTERRUPTED.

      Parameters

      • callback: (timestamp: number) => void

        The callback function to invoke with the event timestamp

      Returns boolean

      true if the callback was set successfully

      client.onMediaConnectionInterrupted((timestamp) => {
      console.log(`Media connection interrupted at ${timestamp}`);
      });
    • Sets a callback for participant join/leave events

      This automatically subscribes to EVENT_PARTICIPANT_JOIN and EVENT_PARTICIPANT_LEAVE. Events are delivered as parsed objects, not raw JSON.

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onParticipantEvent((event, timestamp, participants) => {
      if (event === 'join') {
      participants.forEach(p => console.log(`User joined: ${p.userName} (${p.userId})`));
      } else {
      participants.forEach(p => console.log(`User left: ${p.userId}`));
      }
      });
    • Sets a callback for session update events

      This callback is triggered when session information is updated. It provides details about session status changes (add, stop, pause, resume).

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onSessionUpdate((op, sessionInfo) => {
      // op = SESSION_EVENT_ADD, SESSION_EVENT_STOP, etc.
      console.log(`Session ${sessionInfo.sessionId} updated: ${op}`);
      console.log(`Status: ${sessionInfo.isActive ? 'active' : 'inactive'}`);
      });
    • Sets a callback for sharing start/stop events

      This automatically subscribes to EVENT_SHARING_START and EVENT_SHARING_STOP. Note: These events only work when the RTMS app has DESKSHARE scope permission.

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onSharingEvent((event, timestamp, userId, userName) => {
      if (event === 'start') {
      console.log(`${userName} started sharing`);
      } else {
      console.log('Sharing stopped');
      }
      });
    • Sets a callback for receiving transcript data

      This callback is triggered when transcript data is received from the meeting. It provides the raw transcript data buffer and metadata about the sender.

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onTranscriptData((buffer, size, timestamp, metadata) => {
      // Convert buffer to string (assuming UTF-8 encoding)
      const text = buffer.toString('utf8');
      console.log(`Transcript from ${metadata.userName}: ${text}`);
      });
    • Sets a callback for raw SDK user update events (participant join/leave)

      This is the low-level SDK callback. For most use cases, prefer onParticipantEvent which provides a more convenient API with automatic event subscription.

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onUserUpdate((op, participant) => {
      console.log(`User ${participant.name} (${participant.id}) - op: ${op}`);
      });
    • Sets a callback for receiving video data

      This callback is triggered when video data is received from the meeting. It provides the raw video data buffer, track ID, and metadata about the sender.

      Parameters

      Returns boolean

      true if the callback was set successfully

      client.onVideoData((buffer, size, timestamp, trackId, metadata) => {
      console.log(`Received ${size} bytes of video from ${metadata.userName}`);
      console.log(`Track ID: ${trackId}`);

      // Process the video data
      // buffer - Raw video data (Buffer)
      // size - Size of the video data in bytes
      // timestamp - Timestamp of the video data
      // trackId - ID of the video track
      // metadata - Information about the sender
      });
    • Manually polls for events from the RTMS server

      This method is automatically called by the SDK's internal polling mechanism. You typically don't need to call this manually.

      Returns boolean

      true if the poll operation succeeds

    • Releases client resources

      This method disconnects from the server and releases resources. It's automatically called by the leave method.

      Returns boolean

      true if the release operation succeeds

    • Sets audio parameters for the client (OPTIONAL)

      This method configures audio processing parameters. AudioParams now has sensible defaults, so calling this method is optional. Defaults enable per-participant audio with userId in metadata (dataOpt=AUDIO_MULTI_STREAMS).

      You can override individual fields without setting all parameters:

      Parameters

      • params: AudioParams

        Audio parameters configuration (merges with defaults)

      Returns boolean

      true if the operation succeeds

      // Option 1: Use defaults (no call needed)
      await client.join(...);

      // Option 2: Override just one field
      client.setAudioParams({ channel: rtms.AudioChannel.MONO });

      Error if parameters are invalid or incompatible

    • Sets deskshare parameters for the client

      This method configures deskshare video processing parameters.

      Parameters

      Returns boolean

      true if the operation succeeds

    • Sets video parameters for the client

      This method configures video processing parameters.

      Parameters

      Returns boolean

      true if the operation succeeds

    • Gets the stream ID of the current connection

      Returns string

      The RTMS stream ID

    • Subscribe to receive specific event types

      This method allows you to subscribe to specific event types from the SDK. Note: Typed event callbacks (onParticipantEvent, onActiveSpeakerEvent, etc.) automatically subscribe to their respective events.

      Parameters

      • events: number[]

        Array of event type constants (EVENT_PARTICIPANT_JOIN, etc.)

      Returns boolean

      true if subscription was successful

      // Subscribe to participant events
      client.subscribeEvent([rtms.EVENT_PARTICIPANT_JOIN, rtms.EVENT_PARTICIPANT_LEAVE]);
    • Unsubscribe from specific event types

      This method allows you to unsubscribe from specific event types.

      Parameters

      • events: number[]

        Array of event type constants to unsubscribe from

      Returns boolean

      true if unsubscription was successful

      // Unsubscribe from participant events
      client.unsubscribeEvent([rtms.EVENT_PARTICIPANT_JOIN, rtms.EVENT_PARTICIPANT_LEAVE]);
    • Gets the UUID of the current meeting

      Returns string

      The meeting UUID

    • Initializes the RTMS SDK with the specified CA certificate path

      This static method must be called before creating any Client instances. It's automatically called by the join method if not already initialized.

      Parameters

      • OptionalcaPath: string

        Path to the CA certificate file (defaults to system CA)

      Returns boolean

      true if initialization succeeds

    • Uninitializes the RTMS SDK and releases resources

      This static method should be called when you're done using the SDK. It releases all system resources allocated by the SDK.

      Returns boolean

      true if uninitialization succeeds