SC

SC

new SC(config)

StreamCompanion constructor

Source:
Parameters:
Name Type Description
config Object
Name Type Attributes Default Description
host string

SC Host address

port Number

SC Port number

proto 'http' | 'https'

SC HTTP protocol. This will also change the websocket protocol to wss if https is used here

watchTokens Array.<string>

Default tokens to watch/get

initializeAutomatically boolean <optional>
true

Automatically create and connect to WebSockets

listeners Object
Name Type Attributes Default Description
tokens boolean <optional>
true

Toggle token websocket

mapData boolean <optional>
true

Toggle map data websocket

liveData boolean <optional>
false

Toggle live data websocket

ws Object
Name Type Description
reconnectInterval Number

Reconnect interval

maxTries Number

Max tries to reconnect before emitting an error

Members

(static) osuGrade

Source:

(static) osuStatus

Source:

(static) rawOsuStatus

Source:

Methods

addToken(token) → {Boolean}

Add/register token to the listener

Source:
Parameters:
Name Type Description
token string

Token key/name

Returns:
Type:
Boolean

getBackground() → {Promise.<object>}

Get map background image data

Source:
Returns:
Type:
Promise.<object>

getData(nameopt) → {string|object}

Get name value from map data listener cache if exist. Returns all cached map data if no name is given

Source:
Parameters:
Name Type Attributes Description
name string <optional>

Map data key/name

Returns:
Type:
string | object

Data value string, entire data cache object or null if the data name doesn't exist

getJson() → {Promise.<object>}

Get JSON data of a map

Source:
Returns:
Type:
Promise.<object>

getLiveData(nameopt) → {string|object}

Get name value from live listener cache if exist. Returns all cached live data if no name is given

Source:
Parameters:
Name Type Attributes Description
name string <optional>

Live data key/name

Returns:
Type:
string | object

Live data value string, entire live data cache object or null if the live data name doesn't exist

getOverlayList() → {Promise.<object>}

Get web overlay list

Source:
Returns:
Type:
Promise.<object>

getSettings() → {Promise.<object>}

Get SC settings

Source:
Returns:
Type:
Promise.<object>

getToken(tokenopt) → {string|object}

Get name value from token listener cache if exist. Returns all cached tokens if no name is given

Source:
Parameters:
Name Type Attributes Description
token string <optional>

Token key/name

Returns:
Type:
string | object

Token value string, entire token cache object or null if the token doesn't exist

initialize()

Initialize/Start creating WebSocket clients
You need to run this if config.initializeAutomatically is false

Source:

removeToken(token) → {Boolean}

Remove/unregister token from the listener

Source:
Parameters:
Name Type Description
token string

Token key/name

Returns:
Type:
Boolean

Events

data

Emitted when data is received from any of the enabled websockets

Properties:
Name Type Description
type string

WebSocket type

data any

Received data

Source:
Type:
  • object

disconnect

Emitted when a websocket is disconnected from StreamCompanion

Source:
Type:
  • string

error

Emitted when an expected or unexpected error has occured

Properties:
Name Type Description
ws WebSocket | string | null

WebSocket

error Error | TypeError

Error

Source:
Type:
  • object

ready

Emitted when a websocket is open

Source:
Type:
  • string

reconnecting

Source:
Type:
  • string