Signaling

Extends: EventEmitter

Source: Signaling.js:55

Starts WebSocket connection and manages the messages between peers.

Example

CODE
const millicastSignaling = new Signaling(options)

Constructor

new Signaling(options: Object): Signaling

Parameters

  • options (Object) — General signaling options.
    • options.streamName (String) — Millicast stream name to get subscribed.
    • options.url (String) — WebSocket URL to signal Millicast server and establish a WebRTC connection.

Instance Methods

connect(): Promise.<WebSocket>

Starts a WebSocket connection with signaling server.

Returns

  • Promise.<WebSocket> — Promise object which represents the WebSocket object of the establshed connection.

Fires

  • Signaling#event:wsConnectionSuccess
  • Signaling#event:wsConnectionError
  • Signaling#event:wsConnectionClose
  • Signaling#event:broadcastEvent

Example

CODE
const response = await millicastSignaling.connect()

close()

Close WebSocket connection with Millicast server.

Example

CODE
millicastSignaling.close()

subscribe( sdp: String, options: SignalingSubscribeOptions, ): Promise.<String>

Establish WebRTC connection with Millicast Server as Subscriber role.

Parameters

  • sdp (String) — The SDP information created by your offer.
  • options (SignalingSubscribeOptions) — Signaling Subscribe Options.

Returns

  • Promise.<String> — Promise object which represents the SDP command response.

Example

CODE
const response = await millicastSignaling.subscribe(sdp)

publish( sdp: String, options: SignalingPublishOptions, ): Promise.<String>

Establish WebRTC connection with Millicast Server as Publisher role.

Parameters

  • sdp (String) — The SDP information created by your offer.
  • options (SignalingPublishOptions) — Signaling Publish Options.

Returns

  • Promise.<String> — Promise object which represents the SDP command response.

Example

CODE
const response = await millicastSignaling.publish(sdp, {codec: 'h264'})

cmd(cmd: String, data?: Object): Promise.<Object>

Send command to the server.

Parameters

  • cmd (String) — Command name.
  • data (Object, optional) — Command parameters.

Returns

  • Promise.<Object> — Promise object which represents the command response.

Events

wsConnectionSuccess: Object

WebSocket connection was successfully established with signaling server.

Properties

  • ws (WebSocket) — WebSocket object which represents active connection.
  • tm (TransactionManager) — TransactionManager object that simplify WebSocket commands.

broadcastEvent: Object

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

Properties

  • type (String) — In this case the type of this message is "event".
  • name ("active" | "inactive" | "stopped" | "vad" | "layers" | "migrate" | "viewercount" | "updated") — Event name.
  • data (Object) — Custom event data.

wsConnectionError: String

WebSocket connection failed with signaling server. Returns url of WebSocket

wsConnectionClose

WebSocket connection with signaling server was successfully closed.