Members
name :String
- Source:
Name of the plugin.
Type:
- String
options :Object
- Source:
Options of the plugin.
Type:
- Object
server :server.Server
- Source:
- See:
Instance of soundworks server.
Type:
signals :Object
- Source:
Signals defining the process state.
Type:
- Object
Methods
configure()
- Source:
Helper function to merge default options and user-defined options.
Example
this.options = this.configure(defaults, options);
connect(client)
- Source:
Interface method to implement if specific logic should be done when a server.Client connects to the plugin.
Parameters:
Name | Type | Description |
---|---|---|
client |
server.Client |
disconnect(client)
- Source:
Interface method to implement if specific logic should be done when a server.Client disconnects from the plugin.
Parameters:
Name | Type | Description |
---|---|---|
client |
server.Client |
ready()
- Source:
Method to call in the plugin lifecycle when it should be considered as ready and thus allow the initialization process to continue or the application to start safely (cf. server.AbstractExperience#start).
Example
class MyDelayPlugin extends AbstractPlugin {
// start() is executed when the `start` signal pass to `true`
async start() {
this.state = await this.server.stateManager.create(`s:${this.name}`);
this.started();
// do [async] stuff
setTimeout(() => this.ready(), 3000);
}
}
start()
- Source:
Interface method to override when implementing child class.
The child class MUST call server.AbstractPlugin#started and server.AbstractPlugin#ready
Example
class MyDelayPlugin extends AbstractPlugin {
// start() is executed when the `start` signal pass to `true`
async start() {
this.state = await this.server.stateManager.create(`s:${this.name}`);
this.started();
// do [async] stuff
setTimeout(() => this.ready(), 3000);
}
}
started()
- Source:
Method to call when the plugin is effectively started, as it may have to do some asynchonous job at start (e.g. creating a shared state).
Must be called between before server.AbstractPlugin#ready.
Example
class MyDelayPlugin extends AbstractPlugin {
// start() is executed when the `start` signal pass to `true`
async start() {
this.state = await this.server.stateManager.create(`s:${this.name}`);
this.started();
// do [async] stuff
setTimeout(() => this.ready(), 3000);
}
}