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

Example

let isLoading = false;

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

producer.on('connected', () => {
isLoading = false;
console.log('Connected');
});

producer.on('disconnected', () => {
console.log('Disconnected');
});

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

// To start the stream
try {
isLoading = true;
producer.connect();
} catch (error) {
if (error instanceof CredentialsInvalidError) {
console.log('Credentials are invalid');
}
}

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

Hierarchy

  • Producer

Constructors

  • Parameters

    Returns Producer

    Throws

    • If the options are invalid.

Properties

connector?: default
socket?: IPulseVisionSocket

Methods

  • Connects to PulseVision, requests access to capture the screen, and starts streaming to the room.

    Returns Promise<void>

    Throws

    • If the credentials are invalid.

    Throws

    • If the connection fails.
  • Disconnects from PulseVision and stops streaming to the room.

    Returns Promise<void>

  • Parameters

    • domain: string
    • apiToken: string

    Returns void

  • Stop listening for events.

    Type Parameters

    Parameters

    • event: T

    Returns void

  • Start listening for events.

    Type Parameters

    Parameters

    • event: T
    • callback: ((data) => void)
        • (data): void
        • Parameters

          Returns void

    Returns void

Generated using TypeDoc