Global

Members

client :Client

Description:
  • Instance of soundworks client.

Source:
See:

Instance of soundworks client.

Type:

clients :Set.<ServerClient>

Description:
  • Set of the clients registered in the plugin.

Source:
See:

Set of the clients registered in the plugin.

Type:

server :Server

Description:
  • Instance of soundworks server.

Source:
See:

Instance of soundworks server.

Type:

Methods

(async) addClient(client)

Description:
  • Method called when a client (which registered the client-side plugin), connects to the application. Override this method if you need to perform some particular logic (e.g. creating a shared state) for each clients.

Source:
Parameters:
Name Type Description
client ServerClient

(async) removeClient(client)

Description:
  • Method called when a client (which registered the client-side plugin), disconnects from the application. Override this method if you need to perform some particular logic (e.g. creating a shared state) for each clients.

Source:
Parameters:
Name Type Description
client ServerClient

Type Definitions

ClientAppConfig

Description:
  • Application configuration object.

Source:
Properties:
Name Type Attributes Default Description
name string <optional>
''

Name of the application.

author string <optional>
''

Name of the author.

Application configuration object.

Type:
  • object

ClientConfig

Description:
  • Configuration object for a client running in a browser runtime.

Source:
Properties:
Name Type Description
role string

Role of the client in the application (e.g. 'player', 'controller').

app ClientAppConfig

Application configuration object.

env ClientEnvConfig

Environment configuration object.

Configuration object for a client running in a browser runtime.

Type:
  • object

ClientDescription

Source:
Properties:
Name Type Attributes Default Description
runtime 'browser' | 'node'

Runtime on which the client is aimed at running

default boolean <optional>
false

For browser client, define is the client should be accessible at the default / root HTTP endpoint

Type:
  • object

ClientEnvConfig

Description:
  • Environment configuration object.

Source:
Properties:
Name Type Attributes Default Description
env.port number

Port on which the server is listening.

env.serverAddress string

Domain name or IP of the server. Mandatory when node clients are declared

env.useHttps boolean

Define is the server run in http or in https.

env.baseUrl string <optional>
''

If running behind a proxy, base URL of the application.

Environment configuration object.

Type:
  • objecy

ClientRole

Description:
  • The role of the client in the application.

    For browser client, this information is used to create the URL endpoint.

Source:

The role of the client in the application.

For browser client, this information is used to create the URL endpoint.

Type:
  • string

ServerAppConfig

Description:
  • Application configuration object.

Source:
Properties:
Name Type Attributes Default Description
clients object.<ClientRole, ClientDescription>

Definition of the application clients.

name string <optional>
''

Name of the application.

author string <optional>
''

Name of the author.

Application configuration object.

Type:
  • object

ServerConfig

Description:
  • Configuration object for the server.

Source:
Properties:
Name Type Description
app AppConfig

Application configuration object.

env ServerEnvConfig

Environment configuration object.

Configuration object for the server.

Type:
  • object

ServerEnvConfig

Description:
  • Environment configuration object.

Source:
Properties:
Name Type Attributes Default Description
type 'development' | 'production'

If set to 'production', will enforce some security feature (e.g. blocking access to sensitive APIs, etc.) based on the auth.

port number

Port on which the server is listening.

serverAddress string

Domain name or IP of the server. Mandatory when node clients are declared

useHttps boolean

Define is the server run in http or in https.

httpsInfos object <optional>
null

Path to cert files ( cert, key } for https. If not given and useHttps is true self certified certificates will be created.

Properties
Name Type Attributes Default Description
cert string <optional>
null

Path to cert file.

key string <optional>
null

Path to key file.

auth object <optional>
null

Configuration object for authenticating clients using simple HTTP authentication.

Properties
Name Type Attributes Default Description
client array.<ClientRole> <optional>
[]

List of client role that must authenticate.

login login <optional>
''

Login

password login <optional>
''

Password

env.baseUrl string <optional>
''

If running behind a proxy, base URL of the application.

Environment configuration object.

Type:
  • objecy

SharedStateClassDescription

Description:
  • Description of a SharedState data structure that describes the structure of a class of SharedState to be registered by ServerStateManager#defineClass

    A SharedStateClassDescription is the blueprint, or the definition from which shared states from a given class can be created.

    It consists of a set of key / value pairs where the key is the name of the parameter (cf. ${SharedStateParameterName}), and the value is an object describing the parameter (cf. ${SharedStateParameterDescription}).

Source:

Description of a SharedState data structure that describes the structure of a class of SharedState to be registered by ServerStateManager#defineClass

A SharedStateClassDescription is the blueprint, or the definition from which shared states from a given class can be created.

It consists of a set of key / value pairs where the key is the name of the parameter (cf. ${SharedStateParameterName}), and the value is an object describing the parameter (cf. ${SharedStateParameterDescription}).

Type:
Example
const myClassDescription = {
  triggerSound: {
    type: 'boolean',
    event: true,
  },
  volume: {
    type: 'float'
    default: 0,
    min: -80,
    max: 6,
  }
};

server.stateManager.defineClass('my-class-name', myClassDescription);

SharedStateClassName

Description:
Source:

User defined name for a class of SharedState

Type:
  • string

SharedStateParameterDescription

Description:
Source:
Properties:
Name Type Attributes Default Description
type 'boolean' | 'string' | 'integer' | 'float' | 'enum' | 'any'

Type of the parameter.

default any

Default value of the parameter. Optional only if nullable = true or event = true

nullable boolean <optional>
false

Defines if the parameter is nullable. When true the parameter default is set to null.

event boolean <optional>
false

Define if the parameter is a volatile, i.e. its value only exists on an update and is set back to null after propagation. When true, nullable is automatically set to true and default to null.

filterChange boolean <optional>
true

When set to false, an update will trigger the propagation of a parameter even when its value didn't change. This option provides a sort of middle ground between the default behavior (e.g. where only changed values are propagated) and the behavior of the event option (which has no state per se). Hence, setting this options to false if event=true makes no sens.

immediate boolean <optional>
false

When set to true, an update will trigger the update listeners immediately on the node that generated the update, before propagating the change on the network. This option is useful in cases the network would introduce a noticeable latency on the client. If for some reason the value is overridden server-side (e.g. in an updateHook) the listeners will be called again when the "real" value is received.

required boolean <optional>
false

When set to true, the parameter must be provided in the initialization values when the state is created.

local boolean <optional>
false

When set to true, the parameter is never propagated on the network (hence it is no longer a shared parameter :). This is useful to declare some common parameter (e.g. some interface state) that don't need to be shared but to stay in the shared state API paradigm.

min number <optional>
-Number.MIN_VALUE

Minimum value of the parameter. Only applies for integer and float types.

max number <optional>
Number.MAX_VALUE

Maximum value of the parameter. Only applies for integer and float types.

list Array.<any> <optional>

Possible values of the parameter. Only applies and mandatory for enum type.

metas object <optional>
{}

Optional metadata of the parameter.

Description of a parameter in a class of SharedState

Type:
  • object

SharedStateParameterName

Description:
  • User defined name of a parameter in a class of SharedState

Source:

User defined name of a parameter in a class of SharedState

Type:
  • string

pluginDeleteOnStateChangeCallback()

Description:
Source:

pluginManagerDeleteOnStateChangeCallback()

Description:
Source:

pluginManagerOnStateChangeCallback(fullState, initiator)

Description:
  • Callback executed when a plugin internal state is updated.

Source:
Parameters:
Name Type Description
fullState object.<string, (ClientPlugin|ServerPlugin)>

List of all plugins.

initiator ClientPlugin | ServerPlugin | null

Plugin that initiated the update. The value is null if the change was initiated by the state manager (e.g. when the initialization of the plugins starts).

pluginOnStateChangeCallback(state)

Description:
  • Callback executed when the plugin state is updated.

Source:
Parameters:
Name Type Description
state BasePlugin#state

Current state of the plugin.

(async) serverStateManagerCreateHook(initValues)

Source:
Parameters:
Name Type Description
initValues object

Initialization values object as given when the shared state is created

(async) serverStateManagerDeleteHook(currentValues)

Source:
Parameters:
Name Type Description
currentValues object

Update object as given on a set callback, or result of the previous hook.

(async) serverStateManagerUpdateHook(updates, currentValues) → {object}

Source:
Parameters:
Name Type Description
updates object

Update object as given on a set callback, or result of the previous hook.

currentValues object

Current values of the state.

Returns:

The "real" updates to be applied on the state.

Type
object

sharedStateCollectionDeleteOnAttachCallback()

Description:
Source:

sharedStateCollectionDeleteOnChangeCallback()

Description:
Source:

sharedStateCollectionDeleteOnDetachCallback()

Description:
Source:

sharedStateCollectionDeleteOnUpdateCallback()

Description:
Source:

sharedStateCollectionOnAttachCallback(state)

Description:
  • Callback to execute when an new shared state is added to the collection

Source:
Parameters:
Name Type Description
state SharedState

The newly shared state instance added to the collection.

sharedStateCollectionOnChangeCallback()

Description:
  • Callback to execute when any state of the collection is attached, removed, or updated.

Source:

sharedStateCollectionOnDetachCallback(state)

Description:
  • Callback to execute when an shared state is removed from the collection, i.e. has been deleted by its owner.

Source:
Parameters:
Name Type Description
state SharedState

The shared state instance removed from the collection.

sharedStateCollectionOnUpdateCallback(state, newValues, oldValues)

Description:
  • Callback to execute when an update is triggered on one of the shared states of the collection.

Source:
Parameters:
Name Type Description
state SharedState

The shared state instance that triggered the update.

newValues Object

Key / value pairs of the updates that have been applied to the state.

oldValues Object

Key / value pairs of the updated params before the updates has been applied to the state.

sharedStateDeleteOnUpdateCallback()

Description:
Source:

sharedStateOnUpdateCallback(newValues, oldValues)

Description:
  • Callback executed when updates are applied on a SharedState.

Source:
Parameters:
Name Type Description
newValues Object

Key / value pairs of the updates that have been applied to the state.

oldValues Object

Key / value pairs of the updated params before the updates has been applied to the state.

stateManagerDeleteObserveCallback()

Description:
Source:

(async) stateManagerObserveCallback(className, stateId, nodeId)

Description:
  • Callback executed when a state is created on the network.

Source:
Parameters:
Name Type Description
className string

name of the class

stateId number

id of the state

nodeId number

id of the node that created the state