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:
- Set.<ServerClient>
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:
- object
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 |
||||||||||||||||||||||
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 Properties
|
||||||||||||||||||||
auth |
object |
<optional> |
null
|
Configuration object for authenticating clients using simple HTTP authentication. Properties
|
||||||||||||||||||||
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:
User defined name for a class of SharedState
- Source:
User defined name for a class of SharedState
Type:
- string
SharedStateParameterDescription
- Description:
Description of a parameter in a class of SharedState
- 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 |
boolean |
<optional> |
false
|
Defines if the parameter is nullable.
When |
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 |
required |
boolean |
<optional> |
false
|
When set to true, the parameter must be provided at the creation of the shared state. |
filterChange |
boolean |
<optional> |
true
|
When set to |
immediate |
boolean |
<optional> |
false
|
When set to |
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.
Setting this modifier to |
acknowledge |
boolean |
<optional> |
true
|
When set to false, the acknowledgement
is never sent back to the shared state that initiated an update. This can be
useful to e.g. stream values to the network, but can lead to invalid state.
Setting this modifier to |
min |
number |
<optional> |
-Number.MIN_VALUE
|
Minimum value of the parameter. Only applies
for |
max |
number |
<optional> |
Number.MAX_VALUE
|
Maximum value of the parameter. Only applies
for |
list |
Array.<any> |
<optional> |
Possible values of the parameter. Only applies and
mandatory for |
|
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:
Delete the registered pluginOnStateChangeCallback.
- Source:
pluginManagerDeleteOnStateChangeCallback()
- Description:
Delete the registered pluginManagerOnStateChangeCallback.
- 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 |
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 |
(async) serverStateManagerUpdateHook(updates, currentValues) → {object}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
updates |
object | Update object as given on a |
currentValues |
object | Current values of the state. |
Returns:
The "real" updates to be applied on the state.
- Type
- object
sharedStateCollectionDeleteOnAttachCallback()
- Description:
Delete the registered sharedStateCollectionOnAttachCallback when executed.
- Source:
sharedStateCollectionDeleteOnChangeCallback()
- Description:
Delete the registered sharedStateCollectionOnChangeCallback.
- Source:
sharedStateCollectionDeleteOnDetachCallback()
- Description:
Delete the registered sharedStateCollectionOnDetachCallback when executed.
- Source:
sharedStateCollectionDeleteOnUpdateCallback()
- Description:
Delete the registered sharedStateCollectionOnUpdateCallback when executed.
- 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:
Delete the registered sharedStateOnUpdateCallback.
- 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:
Callback to execute in order to remove a stateManagerObserveCallback from the list of observer.
- 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 |