WebRTCStatsEvents: {
    error(reason: string): void;
    stats(stats: OnStats): void;
}

Events triggered by the WebRTCStats object.

Type declaration

  • error:function
    • Event triggered when an error is triggered by this library.

      Parameters

      • reason: string

        The reason of the error.

      Returns void

      import { WebRTCStats } from '@dolbyio/webrtc-stats';

      const collection = new WebRTCStats({
      getStatsInterval: 1000,
      getStats: () => {
      // TODO: return the statistics.
      },
      });

      collection.on('error', (reason: string) => {
      // An error has been triggered
      console.error(reason);
      });
  • stats:function
    • Event triggered when the statistics are available.

      Parameters

      • stats: OnStats

        The OnStats object that contains the collected WebRTC statistics.

      Returns void

      import { WebRTCStats, OnStats } from '@dolbyio/webrtc-stats';

      const collection = new WebRTCStats({
      getStatsInterval: 1000,
      getStats: () => {
      // TODO: return the statistics.
      },
      });

      collection.on('stats', (stats: OnStats) => {
      // The statistics are available
      console.log(stats);
      });