Global

Type Definitions

ClientConfig

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

Source:
Properties:
Name Type Attributes Description
role string

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

app object <optional>

Application configuration object.

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

Name of the application.

author string <optional>
''

Name of the author.

env object

Environment configuration object.

Properties
Name Type Attributes Default Description
useHttps boolean

Define if the websocket should use secure connection.

serverAddress string

Address the socket server. Mandatory for node clients. For browser clients, use window.location.domain as fallback if empty.

port number 8000

Port of the socket server.

subpath string <optional>
''

If running behind a proxy, path to the application.

Configuration object for a client running in a browser runtime.

Type:
  • object

ServerConfig

Description:
  • Configuration object for the server.

Source:
Properties:
Name Type Attributes Description
app object <optional>

Application configuration object.

Properties
Name Type Attributes Default Description
clients object

Definition of the application clients.

name string <optional>
''

Name of the application.

author string <optional>
''

Name of the author.

env object <optional>

Environment configuration object.

Properties
Name Type Attributes Default Description
useHttps boolean

Define is the server run in http or in https.

serverAddress string

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

port number

Port on which the server is listening.

httpsInfos obj <optional>
null

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

subpath string <optional>
''

If running behind a proxy, path to the application.

Configuration object for the server.

Type:
  • object

SharedStateClassName

Description:
Source:

User defined name for a class of SharedState

Type:
  • string

SharedStateClassSchema

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

    A schema 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#registerSchema

A schema 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 mySchema = {
  triggerSound: {
    type: 'boolean',
    event: true,
  },
  volume: {
    type: 'float'
    default: 0,
    min: -80,
    max: 6,
  }
};

server.stateManager.registerSchema('my-class-name', mySchema);

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 bahavior (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 usefull in cases the network would introduce a noticeable latency on the client. If for some reason the value is overriden server-side (e.g. in an updateHook) the listeners will be called again when the "real" value is received.

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) serverStateManagerUpdateHook(updates, currentValues, contextopt) → {object}

Source:
Parameters:
Name Type Attributes Default Description
updates object

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

currentValues object

Current values of the state.

context object <optional>
null

Optionnal context passed by the creator of the update.

Returns:

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

Type
object

sharedStateCollectionOnUpdateCallback(state, newValues, oldValues, contextopt)

Source:
Parameters:
Name Type Attributes Default Description
state SharedState

State 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.

context Mixed <optional>
null

Optionnal context object that has been passed with the values updates in the set call.

sharedStateDeleteOnUpdateCallback()

Description:
Source:

sharedStateOnUpdateCallback(newValues, oldValues, contextopt)

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

Source:
Parameters:
Name Type Attributes Default 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.

context Mixed <optional>
null

Optionnal context object that has been passed with the values updates in the set call.

stateManagerDeleteObserveCallback()

Description:
Source:

(async) stateManagerObserveCallback(schemaName, stateId, nodeId)

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

Source:
Parameters:
Name Type Description
schemaName string

name of the schema

stateId number

id of the state

nodeId number

id of the node that created the state