BaseWebRTC
Extends: EventEmitter
Source: BaseWebRTC.js:37
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,
): BaseWebRTCParameters
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. A connection attempt still in progress is cancelled and its connect() rejects with an AbortError.
isActive(): Boolean
Get if the current connection is active.
Returns
Boolean
isConnecting(): Boolean
Returns true if a connection attempt is in progress, from the connect() call until the peer connection is established.
Returns
Boolean
runConnectAttempt(
inProgressMessage: String,
connectFn: function,
)
Runs a connection attempt that can be cancelled by stop(). Rejects if another attempt is in progress.
Parameters
inProgressMessage(String) — Error message used when another attempt is in progress.connectFn(function) — Async function performing the attempt, receives the attempt object.
throwIfConnectAttemptCancelled(attempt?: Object)
Throws an AbortError if the connection attempt has been cancelled.
Parameters
attempt(Object, optional) — Connection attempt, none when migrating.
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: