Socket
Socket
Sign inDemoInstall

@soundworks/core

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soundworks/core - npm Package Compare versions

Comparing version 3.0.0-alpha.5 to 3.0.0-alpha.6

68

client/Service.js

@@ -87,12 +87,18 @@ "use strict";

/**
* Method where the initialization logic of a child Service should be
* implemented. When ready, the initialization step should call `this.ready`
* in order to inform the serviceManager that the service is ready to be
* consumed by the client, and thus allow to continue the initialization
* process.
* Interface method to override when implemnting child classes
* The child class MUST call `this.started()` when first init step (creating
* state etc. is done) and `this.ready()` when fully initialized.
*
* @todo - This granularity is especially important client side, so that
* we can give feedback on the initialization steps (e.g. we need the state
* to be synchronized to display usefull feedback or GUIs). This is kept
* that server-side for symetry reasons.
*
* @example
* class MyDelayService extends soundworks.Service {
* // ...
* start() {
* async start() {
* this.state = await this.client.stateManager.attach(`s:${this.name}`);
* this.started();
* // do [async] stuff
* setTimeout(() => this.ready(), 3000);

@@ -105,13 +111,16 @@ * }

start() {
log(`> service "${this.name}" start`);
throw new Error(`service "${this.name}.start()" not implemented`);
}
/**
* Method to call when the service is effectively started, as it may do async
* job at start (cf. platform-service.client).
* Should be called between `start` and `ready`
* job at start (cf. platform-service.client). Must be called between `start`
* and `ready`.
*
* @example
* class MyDelayService extends soundworks.Service {
* // ...
* start() {
* // start() is executed when the `start` signal pass to `true`
* async start() {
* this.state = await this.client.stateManager.attach(`s:${this.name}`);
* this.started();
* // do [async] stuff
* setTimeout(() => this.ready(), 3000);

@@ -124,4 +133,14 @@ * }

started() {
// @note - this as no strong incidence on the initialization lifecycle,
// @note - these check are mostly there for development help. Could be
// replaced with decorators.
if (this.signals.start.value === false) {
throw new Error(`service "${this.name}" cannot "started" before "start"`);
}
if (this.signals.started.value === true) {
throw new Error(`service "${this.name}" cannot be "started" twice`);
} // @note - this as no strong incidence on the initialization lifecycle,
// maybe should be enforced
log(`> service "${this.name}" started`);

@@ -133,2 +152,13 @@ this.signals.started.value = true;

* `ready` and thus allows the intialization process to continue.
*
* @example
* class MyDelayService extends soundworks.Service {
* // ...
* async start() {
* this.state = await this.client.stateManager.attach(`s:${this.name}`);
* this.started();
* // do [async] stuff
* setTimeout(() => this.ready(), 3000);
* }
* }
*/

@@ -138,2 +168,16 @@

ready() {
// @note - these check are mostly there for development help. Could be
// replaced with decorators.
if (this.signals.start.value === false) {
throw new Error(`service "${this.name}" cannot "ready" before "start"`);
}
if (this.signals.started.value === false) {
throw new Error(`service "${this.name}" cannot "ready" before "started"`);
}
if (this.signals.ready.value === true) {
throw new Error(`service "${this.name}" cannot be "ready" twice`);
}
log(`> service "${this.name}" ready`);

@@ -140,0 +184,0 @@ this.signals.ready.value = true;

2

package.json
{
"name": "@soundworks/core",
"version": "3.0.0-alpha.5",
"version": "3.0.0-alpha.6",
"description": "full-stack javascript framework for distributed audio visual experiences on the web",

@@ -5,0 +5,0 @@ "authors": [

# `soundworks`
> @warning: this README relates to v2 and is outdated
<!-- should 200x200 -->

@@ -4,0 +6,0 @@

@@ -91,4 +91,5 @@ "use strict";

disconnect(client) {
// only call exit if the client has fully entered
this.server.stateManager.removeClient(client); // only call exit if the client has fully entered
// (i.e. has finished the its initialization phase)
if (this.clients.has(client)) {

@@ -98,4 +99,2 @@ this.clients.delete(client);

}
this.server.stateManager.removeClient(client);
}

@@ -102,0 +101,0 @@ /**

@@ -85,13 +85,42 @@ "use strict";

}
/** @inheritdoc */
/**
* Interface method to override when implemnting child classes
* The child class MUST call `this.started()` when first init step (creating
* state etc. is done) and `this.ready()` when fully initialized.
*
* @todo - This granularity is especially important client side, so that
* we can give feedback on the initialization steps (e.g. we need the state
* to be synchronized to display usefull feedback or GUIs). We mostly keep
* that server-side for symetry reasons.
*
* @example
* class MyDelayService extends soundworks.Service {
* // start() is executed when the `start` signal pass to `true`
* async start() {
* this.state = await this.client.stateManager.attach(`s:${this.name}`);
* this.started();
* // do [async] stuff
* setTimeout(() => this.ready(), 3000);
* }
* }
*/
start() {// logger.serviceStart(this.name);
start() {
throw new Error(`service "${this.name}.start()" not implemented`);
}
started() {
// @note - this as no strong incidence on the initialization lifecycle,
// maybe should be enforced
_logger.default.serviceStart(this.name);
// @note - these check are mostly there for development help. Could be
// replaced with decorators.
if (this.signals.start.value === false) {
throw new Error(`service "${this.name}" cannot "started" before "start"`);
}
if (this.signals.started.value === true) {
throw new Error(`service "${this.name}" cannot be "started" twice`);
}
_logger.default.serviceStarted(this.name);
this.signals.started.value = true;

@@ -101,3 +130,3 @@ }

* Method to call in the service lifecycle when it should be considered as
* `ready` and thus allows all its dependent activities to start themselves.
* `ready` and thus allows the intialization process to continue.
*/

@@ -107,2 +136,16 @@

ready() {
// @note - these check are mostly there for development help. Could be
// replaced with decorators.
if (this.signals.start.value === false) {
throw new Error(`service "${this.name}" cannot "ready" before "start"`);
}
if (this.signals.started.value === false) {
throw new Error(`service "${this.name}" cannot "ready" before "started"`);
}
if (this.signals.ready.value === true) {
throw new Error(`service "${this.name}" cannot be "ready" twice`);
}
_logger.default.serviceReady(this.name);

@@ -109,0 +152,0 @@

@@ -95,4 +95,4 @@ "use strict";

if (typeof roomsIds === 'string' || Array.isArray(roomIds)) {
if (typeof roomsIds === 'string') {
if (typeof roomIds === 'string' || Array.isArray(roomIds)) {
if (typeof roomIds === 'string') {
roomIds = [roomIds];

@@ -99,0 +99,0 @@ }

@@ -66,3 +66,6 @@ "use strict";

serviceStart(name) {
// serviceStart(name) {
// console.log(` ${name} ${chalk.cyan('start')}`);
// },
serviceStarted(name) {
console.log(` ${name} ${_chalk.default.cyan('started...')}`);

@@ -69,0 +72,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc