Interface ClientEvents<PeerMetadata, TrackMetadata>

interface ClientEvents<PeerMetadata, TrackMetadata> {
    authError: ((reason, client) => void);
    authSuccess: ((client) => void);
    bandwidthEstimationChanged: ((estimation, client) => void);
    componentAdded: ((peer, client) => void);
    componentRemoved: ((peer, client) => void);
    componentUpdated: ((peer, client) => void);
    connectionError: ((error, client) => void);
    deviceDisabled: ((event, client) => void);
    deviceEnabled: ((event, client) => void);
    deviceReady: ((event, client) => void);
    deviceStopped: ((event, client) => void);
    devicesReady: ((event, client) => void);
    devicesStarted: ((event, client) => void);
    disconnectRequested: ((event, client) => void);
    disconnected: ((client) => void);
    encodingChanged: ((context, client) => void);
    error: ((arg, client) => void);
    joinError: ((metadata, client) => void);
    joined: ((event, client) => void);
    localEndpointMetadataChanged: ((event, client) => void);
    localTrackAdded: ((event, client) => void);
    localTrackBandwidthSet: ((event, client) => void);
    localTrackEncodingBandwidthSet: ((event, client) => void);
    localTrackEncodingDisabled: ((event, client) => void);
    localTrackEncodingEnabled: ((event, client) => void);
    localTrackMetadataChanged: ((event, client) => void);
    localTrackMuted: ((event, client) => void);
    localTrackRemoved: ((event, client) => void);
    localTrackReplaced: ((event, client) => void);
    localTrackUnmuted: ((event, client) => void);
    managerInitialized: ((event, client) => void);
    managerStarted: ((event, client) => void);
    peerJoined: ((peer, client) => void);
    peerLeft: ((peer, client) => void);
    peerUpdated: ((peer, client) => void);
    reconnected: ((client) => void);
    reconnectionRetriesLimitReached: ((client) => void);
    reconnectionStarted: ((client) => void);
    socketClose: ((event, client) => void);
    socketError: ((event, client) => void);
    socketOpen: ((event, client) => void);
    targetTrackEncodingRequested: ((event, client) => void);
    trackAdded: ((ctx, client) => void);
    trackReady: ((ctx, client) => void);
    trackRemoved: ((ctx, client) => void);
    trackUpdated: ((ctx, client) => void);
    voiceActivityChanged: ((context, client) => void);
}

Type Parameters

  • PeerMetadata
  • TrackMetadata

Properties

authError: ((reason, client) => void)

Emitted when authentication fails

Type declaration

    • (reason, client): void
    • Parameters

      • reason: "missing token" | "invalid token" | "expired token" | "room not found" | "peer not found"
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

authSuccess: ((client) => void)

Emitted when authentication is successful

Type declaration

bandwidthEstimationChanged: ((estimation, client) => void)

Called every time the server estimates client's bandiwdth.

Type declaration

    • (estimation, client): void
    • Parameters

      • estimation: bigint

        client's available incoming bitrate estimated by the server. It's measured in bits per second.

      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

componentAdded: ((peer, client) => void)

Called each time new Component is added to the room.

Type declaration

componentRemoved: ((peer, client) => void)

Called each time Component is removed from the room.

Type declaration

componentUpdated: ((peer, client) => void)

Called each time Component has its metadata updated.

Type declaration

connectionError: ((error, client) => void)

Called in case of errors related to multimedia session e.g. ICE connection.

Type declaration

    • (error, client): void
    • Parameters

      Returns void

deviceDisabled: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      • event: {
            trackType: TrackType;
        } & {
            mediaDeviceType: MediaDeviceType;
        }
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

deviceEnabled: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      • event: {
            trackType: TrackType;
        } & {
            mediaDeviceType: MediaDeviceType;
        }
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

deviceReady: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      Returns void

deviceStopped: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      • event: {
            trackType: TrackType;
        } & {
            mediaDeviceType: MediaDeviceType;
        }
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

devicesReady: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      • event: {
            audio: DeviceState & {
                restarted: boolean;
            };
            video: DeviceState & {
                restarted: boolean;
            };
        } & {
            mediaDeviceType: MediaDeviceType;
        }
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

devicesStarted: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      • event: {
            audio?: DeviceState & {
                constraints?: string | boolean;
                restarting: boolean;
            };
            video?: DeviceState & {
                constraints?: string | boolean;
                restarting: boolean;
            };
        } & {
            mediaDeviceType: MediaDeviceType;
        }
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

disconnectRequested: ((event, client) => void)

Type declaration

disconnected: ((client) => void)

Emitted when the connection is closed

Type declaration

encodingChanged: ((context, client) => void)

Type declaration

error: ((arg, client) => void)

Type declaration

joinError: ((metadata, client) => void)

Called when peer was not accepted

Type declaration

    • (metadata, client): void
    • Parameters

      • metadata: any

        Pass through for client application to communicate further actions to frontend

      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

joined: ((event, client) => void)

Called when peer was accepted.

Type declaration

localEndpointMetadataChanged: ((event, client) => void)

Type declaration

localTrackAdded: ((event, client) => void)

Type declaration

localTrackBandwidthSet: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      • event: {
            bandwidth: number;
            trackId: string;
        }
        • bandwidth: number
        • trackId: string
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

localTrackEncodingBandwidthSet: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      • event: {
            bandwidth: number;
            rid: string;
            trackId: string;
        }
        • bandwidth: number
        • rid: string
        • trackId: string
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

localTrackEncodingDisabled: ((event, client) => void)

Type declaration

localTrackEncodingEnabled: ((event, client) => void)

Type declaration

localTrackMetadataChanged: ((event, client) => void)

Type declaration

localTrackMuted: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      Returns void

localTrackRemoved: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      Returns void

localTrackReplaced: ((event, client) => void)

Type declaration

localTrackUnmuted: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      Returns void

managerInitialized: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      • event: {
            audio?: DeviceState;
            mediaDeviceType: MediaDeviceType;
            video?: DeviceState;
        }
        • Optional audio?: DeviceState
        • mediaDeviceType: MediaDeviceType
        • Optional video?: DeviceState
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

managerStarted: ((event, client) => void)

Type declaration

    • (event, client): void
    • Parameters

      • event: {
            audio?: DeviceState;
            video?: DeviceState;
        } & {
            mediaDeviceType: MediaDeviceType;
        }
      • client: ClientApi<PeerMetadata, TrackMetadata>

      Returns void

peerJoined: ((peer, client) => void)

Called each time new peer joins the room.

Type declaration

peerLeft: ((peer, client) => void)

Called each time peer leaves the room.

Type declaration

peerUpdated: ((peer, client) => void)

Called each time peer has its metadata updated.

Type declaration

reconnected: ((client) => void)

Emitted on successful reconnection

Type declaration

reconnectionRetriesLimitReached: ((client) => void)

Emitted when the maximum number of reconnection retries is reached

Type declaration

reconnectionStarted: ((client) => void)

Emitted when the process of reconnection starts

Type declaration

socketClose: ((event, client) => void)

Emitted when the websocket connection is closed

Type declaration

socketError: ((event, client) => void)

Emitted when occurs an error in the websocket connection

Type declaration

socketOpen: ((event, client) => void)

Emitted when the websocket connection is opened

Type declaration

targetTrackEncodingRequested: ((event, client) => void)

Type declaration

trackAdded: ((ctx, client) => void)

Called each time the peer which was already in the room, adds new track. Fields track and stream will be set to null. These fields will be set to non-null value in MessageEvents.trackReady

Type declaration

trackReady: ((ctx, client) => void)

Called when data in a new track arrives.

This callback is always called after MessageEvents.trackAdded. It informs user that data related to the given track arrives and can be played or displayed.

Type declaration

trackRemoved: ((ctx, client) => void)

Called when some track will no longer be sent.

It will also be called before MessageEvents.peerLeft for each track of this peer.

Type declaration

trackUpdated: ((ctx, client) => void)

Called each time peer has its track metadata updated.

Type declaration

voiceActivityChanged: ((context, client) => void)

Emitted every time an update about voice activity is received from the server.

Type declaration