StreamEvents

StreamEvents

Subscribe to stream events, such as receiving the amount of viewers of a stream.

These events are handled via a WebSocket with Wowza Video.

Methods

# (static) getEventsLocation() → {String}

Get the current WebSocket stream events location.

By default, wss://streamevents.wowza.com/ws is the location.

Returns:

The stream events location.

Type
String

# (async, static) init() → {Promise.<StreamEvents>}

Initialize the connection with stream events.

Returns:

A promise object that represents the StreamEvents instance once the connection with the stream events is complete.

Type
Promise.<StreamEvents>
Example
const streamEvents = await StreamEvents.init()

# (static) setEventsLocation(url)

Set the WebSocket stream events location.

Parameters:
Name Type Description
url String

The URL for the new stream events location.

# onUserCount(options, streamNameopt, callbackopt)

Subscribe to user count events and invoke the callback once a new message is available.

Parameters:
Name Type Attributes Default Description
options OnUserCountOptions | String

Available user count options.

streamName String <optional>
null

Deprecated. Use the options parameter instead.

callback onUserCountCallback <optional>
null

Deprecated. Use the options parameter instead.

Example
import StreamEvents from '@wowzamediasystems/sdk-rts'

//Create a new instance
const streamEvents = await StreamEvents.init()
const accountId = "Publisher account ID"
const streamName = "Stream Name"
const options = {
   accountId,
   streamName,
   callback: (data) => {
     if (data.error) {
       console.error("Handle error: ", error)
     } else {
       console.log("Viewers: ", data.count)
     }
   }
 }

//Initializes the user count event
streamEvents.onUserCount(options)

# stop()

Stop listening to stream events.

Example
streamEvents.stop()