BaseWebRTC

BaseWebRTC

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

Constructor

# new BaseWebRTC(streamName, tokenGenerator, loggerInstance, autoReconnect)

Parameters:
Name Type Description
streamName String

Millicast existing stream name.

tokenGenerator tokenGeneratorCallback

Callback function executed when a new token is needed.

loggerInstance Object

Logger instance from the extended classes.

autoReconnect Boolean

Enable auto reconnect.

Extends

  • EventEmitter

Methods

# getRTCPeerConnection() → {RTCPeerConnection}

Get current RTC peer connection.

Returns:

Object which represents the RTCPeerConnection.

Type
RTCPeerConnection

# isActive() → {Boolean}

Get if the current connection is active.

Returns:
  • True if connected, false if not.
Type
Boolean

# (async) reconnect(dataopt)

Reconnects to last broadcast.

Parameters:
Name Type Attributes Description
data Object <optional>

This object contains the error property. It may be expanded to contain more information in the future.

Properties
Name Type Description
error String

The value sent in the first reconnect event within the error key of the payload

# setReconnect()

Sets reconnection if autoReconnect is enabled.

# stop()

Stops connection.

Events

# reconnect

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

Type:
  • Object
Properties
Name Type Description
timeout Number

Next retry interval in milliseconds.

error Error

Error object with cause of failure. Possible errors are:

  • Signaling error: wsConnectionError if there was an error in the Websocket connection.
  • Connection state change: RTCPeerConnectionState disconnected if there was an error in the RTCPeerConnection.
  • Attempting to reconnect if the reconnect was trigered externally.
  • Or any internal error thrown by either Publish.connect or View.connect methods