BaseWebRTC

BaseWebRTC

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

Constructor

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

Parameters:
Name Type Description
streamName String

The name of the Wowza Video real-time stream.

tokenGenerator tokenGeneratorCallback

The callback function executed when a new token is needed.

loggerInstance Object

The logger instance from the extended classes.

autoReconnect Boolean

Enable automatic reconnection to the stream.

Extends

  • EventEmitter

Methods

# getRTCPeerConnection() → {RTCPeerConnection}

Get the current RTC peer connection.

Returns:

The RTCPeerConnection.

Type
RTCPeerConnection

# isActive() → {Boolean}

Get whether the current connection is active.

Returns:

True if connected or false if not connected.

Type
Boolean

# (async) reconnect(dataopt)

Reconnect to the 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()

Set up reconnection if autoReconnect is enabled.

# stop()

Stop the connection.

Events

# reconnect

Emit with every reconnection attempt made when an active stream stops unexpectedly.

Type:
  • Object
Properties
Name Type Description
timeout Number

The 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