@pulsevision/producer - v2.5.0
    Preparing search index...

    Class Producer

    The Producer class is used to create a stream from a browser to a PulseVision room.

    import { Producer, RequestTimeoutError } from '@pulsevision/producer';

    const producer = new Producer({
    domain: 'https://app.pulsevision.io',
    apiToken: 'YOUR-API-TOKEN',
    roomName: 'user1',
    meta: { username: 'user1@example.com' },
    debug: true
    });

    producer.on('connect', ({ roomName }) => {
    console.log('Connected to', roomName);
    });

    producer.on('disconnect', ({ roomName }) => {
    console.log('Disconnected from', roomName);
    });

    producer.on('connectionLost', ({ roomName }) => {
    console.log('Connection lost for', roomName);
    });

    producer.on('error', (error) => {
    console.log('Error', error);
    });

    // To start the stream
    try {
    await producer.connect();
    } catch (error) {
    if (error instanceof RequestTimeoutError) {
    console.log('The server did not answer in time');
    }
    }

    // To stop the stream
    await producer.disconnect();

    // To release the instance for good
    producer.destroy();
    Index
    • Connects to PulseVision, requests access to capture the screen, and starts streaming to the room.

      Calling it again while a connection is in flight returns the same promise, and calling it while already connected resolves without doing anything.

      Returns Promise<void>

      • If the server does not answer in time (also matches instanceof CredentialsInvalidError).
      • If the connection fails, with the server's raw error value when the request was answered with an error ACK, or with a RuntimeError when the producer was destroyed.
    • Releases this producer for good: stops the media tracks, clears the preview interval and removes every socket listener immediately. If in a room, sends exitRoom and closes the socket on its ACK or after 1 second. Synchronous, terminal and idempotent - any later connect() rejects.

      Returns void

    • Disconnects from PulseVision and stops streaming to the room. The instance stays reusable: the next connect() uses a fresh room name.

      Returns Promise<void>