BaseWebRTC

Extends: EventEmitter

Source: BaseWebRTC.js:36

Base class for common actions about peer connection and reconnect mechanism for Publishers and Viewer instances.


Constructor

new BaseWebRTC( streamName: String, tokenGenerator: tokenGeneratorCallback, loggerInstance: Object, autoReconnect: Boolean, ): BaseWebRTC

Parameters

  • streamName (String) — Deprecated: Millicast existing stream name. Use tokenGenerator instead.
  • tokenGenerator (tokenGeneratorCallback) — Callback function executed when a new token is needed.
  • loggerInstance (Object) — Logger instance from the extended classes.
  • autoReconnect (Boolean) — Enable auto reconnect.

Instance Methods

getRTCPeerConnection(): RTCPeerConnection

Get current RTC peer connection.

Returns

  • RTCPeerConnection — Object which represents the RTCPeerConnection.

stop()

Stops connection.

isActive(): Boolean

Get if the current connection is active.

Returns

  • Boolean

setReconnect()

Sets reconnection if autoReconnect is enabled.

reconnect(data?: Object)

Reconnects to last broadcast.

Parameters

  • data (Object, optional) — This object contains the error property. It may be expanded to contain more information in the future.

Properties

  • error (String) — The value sent in the first reconnect event within the error key of the payload

Fires

  • BaseWebRTC#event:reconnect

Events

reconnect: Object

Emits with every reconnection attempt made when an active stream stopped unexpectedly.

Properties

  • timeout (Number) — Next retry interval in milliseconds.
  • error (Error) — Error object with cause of failure. Possible errors are: