Signaling

Starts WebSocket connection and manages the messages between peers.

Constructor

new Signaling(options)

Parameters:
NameTypeDescription
optionsObject

General signaling options.

Properties
NameTypeDescription
streamNameString

Millicast stream name to get subscribed.

urlString

WebSocket URL to signal Millicast server and establish a WebRTC connection.

Example
const millicastSignaling = new Signaling(options)

Extends

  • EventEmitter

Methods

close()

Close WebSocket connection with Millicast server.

Example
millicastSignaling.close()

(async) cmd(cmd, dataopt) → {Promise.<Object>}

Send command to the server.

Parameters:
NameTypeAttributesDescription
cmdString

Command name.

dataObject<optional>

Command parameters.

Returns:

Promise object which represents the command response.

Type: 
Promise.<Object>

(async) connect() → {Promise.<WebSocket>}

Starts a WebSocket connection with signaling server.

Returns:

Promise object which represents the WebSocket object of the establshed connection.

Type: 
Promise.<WebSocket>
Example
const response = await millicastSignaling.connect()

(async) publish(sdp, options) → {Promise.<String>}

Establish WebRTC connection with Millicast Server as Publisher role.

Parameters:
NameTypeDescription
sdpString

The SDP information created by your offer.

optionsSignalingPublishOptions

Signaling Publish Options.

Returns:

Promise object which represents the SDP command response.

Type: 
Promise.<String>
Example
const response = await millicastSignaling.publish(sdp, {codec: 'h264'})

(async) subscribe(sdp, options) → {Promise.<String>}

Establish WebRTC connection with Millicast Server as Subscriber role.

Parameters:
NameTypeDescription
sdpString

The SDP information created by your offer.

optionsSignalingSubscribeOptions

Signaling Subscribe Options.

Returns:

Promise object which represents the SDP command response.

Type: 
Promise.<String>
Example
const response = await millicastSignaling.subscribe(sdp)

Events

broadcastEvent

Passthrough of available Millicast broadcast events.

Active - Fires when the live stream is, or has started broadcasting.

Inactive - Fires when the stream has stopped broadcasting, but is still available.

Stopped - Fires when the stream has stopped for a given reason.

Vad - Fires when using multiplexed tracks for audio.

Layers - Fires when there is an update of the state of the layers in a stream (when broadcasting with simulcast).

Migrate - Fires when the server is having problems, is shutting down or when viewers need to move for load balancing purposes.

Viewercount - Fires when the viewer count changes.

Updated - when an active stream's tracks are updated

More information here: https://docs.dolby.io/streaming-apis/docs/web#broadcast-events

Type:
  • Object
Properties
NameTypeDescription
typeString

In this case the type of this message is "event".

name"active" | "inactive" | "stopped" | "vad" | "layers" | "migrate" | "viewercount" | "updated"

Event name.

dataObject

Custom event data.

wsConnectionClose

WebSocket connection with signaling server was successfully closed.

wsConnectionError

WebSocket connection failed with signaling server. Returns url of WebSocket

Type:
  • String

wsConnectionSuccess

WebSocket connection was successfully established with signaling server.

Type:
  • Object
Properties
NameTypeDescription
wsWebSocket

WebSocket object which represents active connection.

tmTransactionManager

TransactionManager object that simplify WebSocket commands.