@soundworks/core 4.0.0-alpha.28 → 4.0.0-alpha.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsdoc +3 -1
- package/CHANGELOG.md +11 -5
- package/package.json +5 -5
- package/src/client/Client.js +78 -83
- package/src/client/{Context.js → ClientContext.js} +48 -38
- package/src/client/ClientContextManager.js +115 -0
- package/src/client/{Plugin.js → ClientPlugin.js} +22 -18
- package/src/client/{PluginManager.js → ClientPluginManager.js} +39 -35
- package/src/client/{Socket.js → ClientSocket.js} +54 -65
- package/src/client/{StateManager.js → ClientStateManager.js} +7 -8
- package/src/client/index.js +17 -41
- package/src/common/BasePlugin.js +56 -51
- package/src/common/BasePluginManager.js +175 -139
- package/src/common/BaseStateManager.js +316 -120
- package/src/common/BatchedTransport.js +24 -24
- package/src/common/ParameterBag.js +18 -6
- package/src/common/PromiseStore.js +1 -0
- package/src/common/{BaseSharedState.js → SharedState.js} +271 -199
- package/src/common/{BaseSharedStateCollection.js → SharedStateCollection.js} +92 -61
- package/src/common/logger.js +5 -0
- package/src/common/shared-state-types.js +76 -0
- package/src/common/version.js +1 -1
- package/src/server/Server.js +391 -354
- package/src/server/ServerClient.js +73 -0
- package/src/server/{Context.js → ServerContext.js} +85 -66
- package/src/server/{ContextManager.js → ServerContextManager.js} +98 -85
- package/src/server/{Plugin.js → ServerPlugin.js} +10 -24
- package/src/server/{PluginManager.js → ServerPluginManager.js} +76 -69
- package/src/server/{Socket.js → ServerSocket.js} +19 -18
- package/src/server/{Sockets.js → ServerSockets.js} +36 -27
- package/src/server/ServerStateManager.js +515 -0
- package/src/{common → server}/SharedStatePrivate.js +61 -26
- package/src/server/audit-schema.js +1 -1
- package/src/server/crypto.js +2 -0
- package/src/server/index.js +18 -21
- package/types/client/Client.d.ts +74 -95
- package/types/client/{Context.d.ts → ClientContext.d.ts} +25 -26
- package/types/client/{ContextManager.d.ts → ClientContextManager.d.ts} +19 -22
- package/types/client/{Plugin.d.ts → ClientPlugin.d.ts} +17 -20
- package/types/client/{PluginManager.d.ts → ClientPluginManager.d.ts} +13 -36
- package/types/client/ClientSocket.d.ts +74 -0
- package/types/client/{StateManager.d.ts → ClientStateManager.d.ts} +11 -15
- package/types/client/index.d.ts +26 -2
- package/types/common/BasePlugin.d.ts +52 -46
- package/types/common/BasePluginManager.d.ts +68 -44
- package/types/common/BaseStateManager.d.ts +207 -97
- package/types/common/BatchedTransport.d.ts +1 -5
- package/types/common/ParameterBag.d.ts +16 -18
- package/types/common/PromiseStore.d.ts +1 -1
- package/types/common/SharedState.d.ts +297 -0
- package/types/common/{BaseSharedStateCollection.d.ts → SharedStateCollection.d.ts} +34 -18
- package/types/common/constants.d.ts +0 -2
- package/types/common/logger.d.ts +2 -1
- package/types/common/shared-state-types.d.ts +83 -0
- package/types/common/sockets-utils.d.ts +0 -5
- package/types/common/version.d.ts +1 -2
- package/types/server/Server.d.ts +78 -132
- package/types/server/ServerClient.d.ts +45 -0
- package/types/server/{Context.d.ts → ServerContext.d.ts} +53 -43
- package/types/server/ServerContextManager.d.ts +80 -0
- package/types/server/{Plugin.d.ts → ServerPlugin.d.ts} +19 -33
- package/types/server/{PluginManager.d.ts → ServerPluginManager.d.ts} +39 -37
- package/types/server/ServerSocket.d.ts +85 -0
- package/types/server/ServerSockets.d.ts +50 -0
- package/types/server/ServerStateManager.d.ts +189 -0
- package/types/server/SharedStatePrivate.d.ts +21 -0
- package/types/server/audit-network-latency.worker.d.ts +1 -2
- package/types/server/audit-schema.d.ts +0 -1
- package/types/server/crypto.d.ts +2 -1
- package/types/server/index.d.ts +24 -2
- package/src/client/ContextManager.js +0 -111
- package/src/client/SharedState.js +0 -84
- package/src/client/SharedStateCollection.js +0 -38
- package/src/server/Client.js +0 -55
- package/src/server/SharedState.js +0 -85
- package/src/server/SharedStateCollection.js +0 -39
- package/src/server/StateManager.js +0 -696
- package/types/client/Client.d.ts.map +0 -1
- package/types/client/Context.d.ts.map +0 -1
- package/types/client/ContextManager.d.ts.map +0 -1
- package/types/client/Plugin.d.ts.map +0 -1
- package/types/client/PluginManager.d.ts.map +0 -1
- package/types/client/SharedState.d.ts +0 -85
- package/types/client/SharedState.d.ts.map +0 -1
- package/types/client/SharedStateCollection.d.ts +0 -41
- package/types/client/SharedStateCollection.d.ts.map +0 -1
- package/types/client/Socket.d.ts +0 -149
- package/types/client/Socket.d.ts.map +0 -1
- package/types/client/StateManager.d.ts.map +0 -1
- package/types/client/index.d.ts.map +0 -1
- package/types/common/BasePlugin.d.ts.map +0 -1
- package/types/common/BasePluginManager.d.ts.map +0 -1
- package/types/common/BaseSharedState.d.ts +0 -244
- package/types/common/BaseSharedState.d.ts.map +0 -1
- package/types/common/BaseSharedStateCollection.d.ts.map +0 -1
- package/types/common/BaseStateManager.d.ts.map +0 -1
- package/types/common/BatchedTransport.d.ts.map +0 -1
- package/types/common/ParameterBag.d.ts.map +0 -1
- package/types/common/PromiseStore.d.ts.map +0 -1
- package/types/common/SharedStatePrivate.d.ts +0 -21
- package/types/common/SharedStatePrivate.d.ts.map +0 -1
- package/types/common/constants.d.ts.map +0 -1
- package/types/common/logger.d.ts.map +0 -1
- package/types/common/sockets-utils.d.ts.map +0 -1
- package/types/common/version.d.ts.map +0 -1
- package/types/server/Client.d.ts +0 -45
- package/types/server/Client.d.ts.map +0 -1
- package/types/server/Context.d.ts.map +0 -1
- package/types/server/ContextManager.d.ts +0 -69
- package/types/server/ContextManager.d.ts.map +0 -1
- package/types/server/Plugin.d.ts.map +0 -1
- package/types/server/PluginManager.d.ts.map +0 -1
- package/types/server/Server.d.ts.map +0 -1
- package/types/server/SharedState.d.ts +0 -86
- package/types/server/SharedState.d.ts.map +0 -1
- package/types/server/SharedStateCollection.d.ts +0 -41
- package/types/server/SharedStateCollection.d.ts.map +0 -1
- package/types/server/Socket.d.ts +0 -164
- package/types/server/Socket.d.ts.map +0 -1
- package/types/server/Sockets.d.ts +0 -80
- package/types/server/Sockets.d.ts.map +0 -1
- package/types/server/StateManager.d.ts +0 -405
- package/types/server/StateManager.d.ts.map +0 -1
- package/types/server/audit-network-latency.worker.d.ts.map +0 -1
- package/types/server/audit-schema.d.ts.map +0 -1
- package/types/server/crypto.d.ts.map +0 -1
- package/types/server/index.d.ts.map +0 -1
package/types/server/Client.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export default Client;
|
|
2
|
-
/**
|
|
3
|
-
* Server-side representation of a `soundworks` client.
|
|
4
|
-
*
|
|
5
|
-
* @memberof server
|
|
6
|
-
* @hideconstructor
|
|
7
|
-
* @see {@link client.Client}
|
|
8
|
-
*/
|
|
9
|
-
declare class Client {
|
|
10
|
-
/**
|
|
11
|
-
* @param {String} role - Role of the client
|
|
12
|
-
* @param {server.Socket} socket - Socket connection with the client
|
|
13
|
-
*/
|
|
14
|
-
constructor(role: string, socket: server.Socket);
|
|
15
|
-
/**
|
|
16
|
-
* Client role, as specified in client side config {@link client.Client}.
|
|
17
|
-
*
|
|
18
|
-
* @type {String}
|
|
19
|
-
*/
|
|
20
|
-
role: string;
|
|
21
|
-
/**
|
|
22
|
-
* Session Id (incremented positive number).
|
|
23
|
-
*
|
|
24
|
-
* @type {Number}
|
|
25
|
-
*/
|
|
26
|
-
id: number;
|
|
27
|
-
/**
|
|
28
|
-
* Unique session Id (uuidv4).
|
|
29
|
-
*
|
|
30
|
-
* @type {String}
|
|
31
|
-
*/
|
|
32
|
-
uuid: string;
|
|
33
|
-
/**
|
|
34
|
-
* Socket connection with the remote client {@link client.Client}.
|
|
35
|
-
*
|
|
36
|
-
* @type {server.Socket}
|
|
37
|
-
*/
|
|
38
|
-
socket: server.Socket;
|
|
39
|
-
/**
|
|
40
|
-
* Is set in server._onSocketConnection
|
|
41
|
-
* @private
|
|
42
|
-
*/
|
|
43
|
-
private token;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=Client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/server/Client.js"],"names":[],"mappings":";AAKA;;;;;;GAMG;AACH;IACE;;;OAGG;IACH,iDAkCC;IAjCC;;;;OAIG;IACH,aAAgB;IAEhB;;;;OAIG;IACH,WAAiC;IAEjC;;;;OAIG;IACH,aAAkB;IAElB;;;;OAIG;IACH,sBAAoB;IAEpB;;;OAGG;IACH,cAAiB;CAEpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/server/Context.js"],"names":[],"mappings":";AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH;IACE;;;;;;;;OAQG;IACH,iCAPW,MAAM,GAAC,MAAM,EAAE,EA+CzB;IAnCC;;;;OAIG;IACH,+BAAoB;IAEpB;;;OAGG;IACH,SAFU,eAAe,CAED;IAExB;;;;OAIG;IACH,iBAHU,MAAM,CAGI;IAapB,mBAA2B;IAM7B;;;;;;;;;;;;;;;;OAgBG;IACH,4BAEC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,uBAAgB;IAEhB;;;;;;OAMG;IACH,sBAAe;IAEf;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,2CAMC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,0CAMC;CACF"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
export default ContextManager;
|
|
2
|
-
/**
|
|
3
|
-
* Manage the different server-side contexts and their lifecycle. The `ContextManager`
|
|
4
|
-
* is automatically instantiated by the {@link server.Server}.
|
|
5
|
-
*
|
|
6
|
-
* _WARNING: Most of the time, you should not have to manipulate the context manager directly._
|
|
7
|
-
*
|
|
8
|
-
* @memberof server
|
|
9
|
-
* @hideconstructor
|
|
10
|
-
*/
|
|
11
|
-
declare class ContextManager {
|
|
12
|
-
/**
|
|
13
|
-
* @param {server.Server} server - Instance of the soundworks server.
|
|
14
|
-
*/
|
|
15
|
-
constructor(server: server.Server);
|
|
16
|
-
/** @private */
|
|
17
|
-
private server;
|
|
18
|
-
/** @private */
|
|
19
|
-
private _contexts;
|
|
20
|
-
/** @private */
|
|
21
|
-
private _contextStartPromises;
|
|
22
|
-
/**
|
|
23
|
-
* Register a context in the manager.
|
|
24
|
-
* This method is called in the {@link server.Context} constructor
|
|
25
|
-
*
|
|
26
|
-
* @param {server.Context} context - Context instance to register.
|
|
27
|
-
*
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
private register;
|
|
31
|
-
/**
|
|
32
|
-
* Retrieve a started context from its name.
|
|
33
|
-
*
|
|
34
|
-
* _WARNING: Most of the time, you should not have to call this method manually._
|
|
35
|
-
*
|
|
36
|
-
* @param {server.Context#name} contextName - Name of the context.
|
|
37
|
-
*/
|
|
38
|
-
get(contextName: any): Promise<any>;
|
|
39
|
-
/**
|
|
40
|
-
* Called when a client connects to the server (websocket handshake)
|
|
41
|
-
*
|
|
42
|
-
* @param {server.Client} client
|
|
43
|
-
*
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
private addClient;
|
|
47
|
-
/**
|
|
48
|
-
* Called when a client connects to the server (websocket 'close' event)
|
|
49
|
-
*
|
|
50
|
-
* @param {server.Client} client
|
|
51
|
-
*
|
|
52
|
-
* @private
|
|
53
|
-
*/
|
|
54
|
-
private removeClient;
|
|
55
|
-
/**
|
|
56
|
-
* Start all contexts registered before `await server.start()`.
|
|
57
|
-
* Called on {@link server.Server#start}
|
|
58
|
-
*
|
|
59
|
-
* @private
|
|
60
|
-
*/
|
|
61
|
-
private start;
|
|
62
|
-
/**
|
|
63
|
-
* Stop all contexts. Called on {@link server.Server#stop}
|
|
64
|
-
*
|
|
65
|
-
* @private
|
|
66
|
-
*/
|
|
67
|
-
private stop;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=ContextManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContextManager.d.ts","sourceRoot":"","sources":["../../src/server/ContextManager.js"],"names":[],"mappings":";AAoDA;;;;;;;;GAQG;AACH;IACE;;OAEG;IACH,mCAOC;IANC,eAAe;IACf,eAAoB;IACpB,eAAe;IACf,kBAAwC;IACxC,eAAe;IACf,8BAAsC;IAGxC;;;;;;;OAOG;IACH,iBAOC;IAED;;;;;;OAMG;IACH,oCAyBC;IAED;;;;;;OAMG;IACH,kBAyFC;IAED;;;;;;OAMG;IACH,qBAUC;IAED;;;;;OAKG;IACH,cAGC;IAED;;;;OAIG;IACH,aAGC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/server/Plugin.js"],"names":[],"mappings":";;;;;2BAMW,aAAa;;AAJxB;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH;IACE;;;;OAIG;IACH,uCAHW,MAAM,EAehB;IATC;;;;OAIG;IACH,sBAAoB;IAEpB,eAAe;IACf,gBAAwB;IAG1B;;;;;;OAMG;IACH,gDAEC;IAED;;;;;;OAMG;IACH,mDAEC;CACF;uBA3EsB,yBAAyB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../src/server/PluginManager.js"],"names":[],"mappings":";;;;;4BAQW,MAAM,aACN,gBAAc,IAAI;;AAL7B;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH;IASE,mEAQC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAMC;IAID,cAAc;IACd,qDAYC;IAED,eAAe;IACf,kBAUC;IAED,eAAe;IACf,qBAUC;CACF;8BAvK6B,gCAAgC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../src/server/Server.js"],"names":[],"mappings":";;;;;AAuGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH;IACE;;;;;;;;OAQG;IACH,yCAoLC;IA/KC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,YAA+C;IAuC/C,gBAAsB;IAEtB;;;;;;;;;;;;;;;;OAgBG;IAGH,YAAuB;IAIvB;;;;;OAKG;IACH,gBAAsB;IAEtB;;;;;OAKG;IACH,wBAA4B;IAE5B;;;;;OAKG;IACH,oCAA4C;IAE5C;;;;;OAKG;IACH,kCAAsC;IAEtC;;;;;OAKG;IACH,sCAA8C;IAE9C;;;OAGG;IACH;;;;;;;;;;;;;;;;;;;;;;;;MAAsB;IAEtB;;;;OAIG;IACH,QAFU,MAAM,CAEI;IAEpB;;;;;;OAMG;IACH,WAAyC;IAEzC,eAAe;IACf,oCAIC;IAED,eAAe;IACf,iCAAyC;IACzC,eAAe;IACf,kCAA0C;IAC1C,eAAe;IACf,qCAA6C;IAC7C,eAAe;IACf,oBAAuB;IACvB,eAAe;IACf,iCAAyC;IACzC,eAAe;IACf,wBAAgC;IASlC;;;;OAIG;IACH,0BAEC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,sBAgPC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,sBAwFC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,sBAgBC;IAED;;;OAGG;IACH,yBA2EC;IAED,8CAIC;IAED,iDAIC;IAED;;;OAGG;IACH,4BAkHC;IAED;;;;;;;OAOG;IACH,2BAmBC;IAED,6CAIC;IAED,eAAe;IACf,wBAgBC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,sCAkDC;IAED;;;;;OAKG;IACH,wDAEC;IAED;;;;;;;;;;;;;;;OAeG;IACH,iBAPa,2BAA2B,CAavC;IAED,eAAe;IACf,oBAMC;IAED,eAAe;IACf,+BAkBC;IAED;;;;;;OAMG;IACH,gDAMC;IAED;;;;;;;;OAQG;IAEH,2EAkBC;CACF"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
export default SharedState;
|
|
2
|
-
export namespace server {
|
|
3
|
-
/**
|
|
4
|
-
* ~onUpdateCallback
|
|
5
|
-
*/
|
|
6
|
-
type SharedState = (newValues: any, oldValues: any, context?: Mixed) => any;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* @callback server.SharedState~onUpdateCallback
|
|
10
|
-
* @param {Object} newValues - Key / value pairs of the updates that have been
|
|
11
|
-
* applied to the state.
|
|
12
|
-
* @param {Object} oldValues - Key / value pairs of the updated params before
|
|
13
|
-
* the updates has been applied to the state.
|
|
14
|
-
* @param {Mixed} [context=null] - Optionnal context object that has been passed
|
|
15
|
-
* with the values updates in the `set` call.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Delete the registered {@link server.SharedState~onUpdateCallback}.
|
|
19
|
-
*
|
|
20
|
-
* @callback server.SharedState~deleteOnUpdateCallback
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* The `SharedState` is one of the most important and versatile abstraction provided
|
|
24
|
-
* by `soundworks`. It represents a set of parameters that are synchronized accross
|
|
25
|
-
* every nodes of the application (clients and server) that declared some interest
|
|
26
|
-
* to the shared state.
|
|
27
|
-
*
|
|
28
|
-
* A `SharedState` is created according to a "schema" (in the sense of a database
|
|
29
|
-
* schema) that must be declared and registered server-side. Any number of `SharedState`s
|
|
30
|
-
* can be created from a single schema.
|
|
31
|
-
*
|
|
32
|
-
* A shared state can be created both by the clients or by the server (in which case
|
|
33
|
-
* it is generally considered as a global state of the application). Similarly any
|
|
34
|
-
* node of the application (clients or server) can declare interest and "attach" to
|
|
35
|
-
* a state created by another node. All node attached to a state can modify its values
|
|
36
|
-
* and/or react to the modifications applied by other nodes.
|
|
37
|
-
*
|
|
38
|
-
* Tutorial: {@link https://soundworks.dev/guide/state-manager.html}
|
|
39
|
-
*
|
|
40
|
-
* ```
|
|
41
|
-
* // server-side
|
|
42
|
-
* import { Server } from '@soundworks/server/index.js';
|
|
43
|
-
*
|
|
44
|
-
* const server = new Server(config);
|
|
45
|
-
* // declare and register the schema of a shared state.
|
|
46
|
-
* server.stateManager.registerSchema('some-global-state', {
|
|
47
|
-
* myRandom: {
|
|
48
|
-
* type: 'float',
|
|
49
|
-
* default: 0,
|
|
50
|
-
* }
|
|
51
|
-
* });
|
|
52
|
-
*
|
|
53
|
-
* await server.start();
|
|
54
|
-
*
|
|
55
|
-
* // create a global state server-side
|
|
56
|
-
* const globalState = await server.stateManager.create('some-global-state');
|
|
57
|
-
* // listen and react to the changes made by the clients
|
|
58
|
-
* globalState.onUpdate(updates => console.log(updates));
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* ```
|
|
62
|
-
* // client-side
|
|
63
|
-
* import { Client } from '@soundworks/client.index.js';
|
|
64
|
-
*
|
|
65
|
-
* const client = new Client(config);
|
|
66
|
-
* await client.start();
|
|
67
|
-
*
|
|
68
|
-
* // attach to the global state created by the server
|
|
69
|
-
* const globalState = await client.stateManager.attach('some-global-state');
|
|
70
|
-
*
|
|
71
|
-
* // update the value of a `myRandom` parameter every seconds
|
|
72
|
-
* setInterval(() => {
|
|
73
|
-
* globalState.set({ myRandom: Math.random() });
|
|
74
|
-
* }, 1000);
|
|
75
|
-
* ``
|
|
76
|
-
*
|
|
77
|
-
* @memberof server
|
|
78
|
-
* @extends BaseSharedState
|
|
79
|
-
* @inheritdoc
|
|
80
|
-
* @hideconstructor
|
|
81
|
-
* @see {server.StateManager}
|
|
82
|
-
*/
|
|
83
|
-
declare class SharedState extends BaseSharedState {
|
|
84
|
-
}
|
|
85
|
-
import BaseSharedState from '../common/BaseSharedState.js';
|
|
86
|
-
//# sourceMappingURL=SharedState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SharedState.d.ts","sourceRoot":"","sources":["../../src/server/SharedState.js"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH;CAA4C;4BAjFhB,8BAA8B"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export default SharedStateCollection;
|
|
2
|
-
export namespace server {
|
|
3
|
-
/**
|
|
4
|
-
* ~onUpdateCallback
|
|
5
|
-
*/
|
|
6
|
-
type SharedStateCollection = (state: server.SharedState, newValues: any, oldValues: any, context?: Mixed) => any;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* @callback server.SharedStateCollection~onUpdateCallback
|
|
10
|
-
* @param {server.SharedState} state - State that triggered the update.
|
|
11
|
-
* @param {Object} newValues - Key / value pairs of the updates that have been
|
|
12
|
-
* applied to the state.
|
|
13
|
-
* @param {Object} oldValues - Key / value pairs of the updated params before
|
|
14
|
-
* the updates has been applied to the state.
|
|
15
|
-
* @param {Mixed} [context=null] - Optionnal context object that has been passed
|
|
16
|
-
* with the values updates in the `set` call.
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* The `SharedStateCollection` interface represent a collection of all states
|
|
20
|
-
* created from a given schema name on the network.
|
|
21
|
-
*
|
|
22
|
-
* It can optionnaly exclude the states created by the current node.
|
|
23
|
-
*
|
|
24
|
-
* See {@link server.StateManager#getCollection} for factory method API
|
|
25
|
-
*
|
|
26
|
-
* ```
|
|
27
|
-
* const collection = await server.stateManager.getCollection('my-schema');
|
|
28
|
-
* const allValues = collection.getValues();
|
|
29
|
-
* collection.onUpdate((state, newValues, oldValues, context) => {
|
|
30
|
-
* // do something
|
|
31
|
-
* });
|
|
32
|
-
* ```
|
|
33
|
-
* @memberof server
|
|
34
|
-
* @extends BaseSharedStateCollection
|
|
35
|
-
* @inheritdoc
|
|
36
|
-
* @hideconstructor
|
|
37
|
-
*/
|
|
38
|
-
declare class SharedStateCollection extends BaseSharedStateCollection {
|
|
39
|
-
}
|
|
40
|
-
import BaseSharedStateCollection from '../common/BaseSharedStateCollection.js';
|
|
41
|
-
//# sourceMappingURL=SharedStateCollection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SharedStateCollection.d.ts","sourceRoot":"","sources":["../../src/server/SharedStateCollection.js"],"names":[],"mappings":";;;;;;;AAIA;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH;CAAgE;sCAnC1B,wCAAwC"}
|
package/types/server/Socket.d.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
export default Socket;
|
|
2
|
-
/**
|
|
3
|
-
* The Socket class is a simple publish / subscribe wrapper built on top of the
|
|
4
|
-
* [ws](https://github.com/websockets/ws) library. An instance of {@link server.Socket}
|
|
5
|
-
* is automatically created per client when it connects (see {@link server.Client#socket}).
|
|
6
|
-
*
|
|
7
|
-
* _Important: In most cases, you should consider using a {@link client.SharedState}
|
|
8
|
-
* rather than directly using the sockets._
|
|
9
|
-
*
|
|
10
|
-
* The Socket class contains two different WebSockets:
|
|
11
|
-
* - a socket configured with `binaryType = 'blob'` for JSON compatible data
|
|
12
|
-
* types (i.e. string, number, boolean, object, array and null).
|
|
13
|
-
* - a socket configured with `binaryType= 'arraybuffer'` for efficient streaming
|
|
14
|
-
* of binary data.
|
|
15
|
-
*
|
|
16
|
-
* @memberof server
|
|
17
|
-
* @hideconstructor
|
|
18
|
-
*/
|
|
19
|
-
declare class Socket {
|
|
20
|
-
constructor(ws: any, binaryWs: any, rooms: any, sockets: any);
|
|
21
|
-
/**
|
|
22
|
-
* `ws` socket instance configured with `binaryType=blob` (string)
|
|
23
|
-
*
|
|
24
|
-
* @type {object}
|
|
25
|
-
* @private
|
|
26
|
-
*/
|
|
27
|
-
private ws;
|
|
28
|
-
/**
|
|
29
|
-
* `ws` socket instance configured with `binaryType=arraybuffer` (TypedArray)
|
|
30
|
-
*
|
|
31
|
-
* @type {object}
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
private binaryWs;
|
|
35
|
-
/**
|
|
36
|
-
* Reference to the sockets object, is mainly dedicated to allow
|
|
37
|
-
* broadcasting from a given socket instance.
|
|
38
|
-
*
|
|
39
|
-
* @type {server.Sockets}
|
|
40
|
-
* @example
|
|
41
|
-
* socket.sockets.broadcast('my-room', this, 'update-value', 1);
|
|
42
|
-
*/
|
|
43
|
-
sockets: server.Sockets;
|
|
44
|
-
/**
|
|
45
|
-
* Reference to the rooms object
|
|
46
|
-
*
|
|
47
|
-
* @type {Map}
|
|
48
|
-
* @private
|
|
49
|
-
*/
|
|
50
|
-
private rooms;
|
|
51
|
-
/** @private */
|
|
52
|
-
private _stringListeners;
|
|
53
|
-
/** @private */
|
|
54
|
-
private _binaryListeners;
|
|
55
|
-
/** @private */
|
|
56
|
-
private _heartbeatId;
|
|
57
|
-
/** @private */
|
|
58
|
-
private _isAlive;
|
|
59
|
-
/**
|
|
60
|
-
* Removes all listeners and immediately close the two sockets. Is automatically
|
|
61
|
-
* called on `server.stop()`
|
|
62
|
-
*
|
|
63
|
-
* @private
|
|
64
|
-
*/
|
|
65
|
-
private terminate;
|
|
66
|
-
/**
|
|
67
|
-
* @param {boolean} binary - Emit to either the string or binary socket.
|
|
68
|
-
* @param {string} channel - Channel name.
|
|
69
|
-
* @param {...*} args - Content of the message.
|
|
70
|
-
* @private
|
|
71
|
-
*/
|
|
72
|
-
private _emit;
|
|
73
|
-
/**
|
|
74
|
-
* @param {Function[]} listeners - List of listeners, either for the string or binary socket.
|
|
75
|
-
* @param {string} channel - Channel name.
|
|
76
|
-
* @param {Function} callback - The function to be added to the listeners.
|
|
77
|
-
* @private
|
|
78
|
-
*/
|
|
79
|
-
private _addListener;
|
|
80
|
-
/**
|
|
81
|
-
* @param {Function[]} listeners - List of listeners, either for the string or binary socket.
|
|
82
|
-
* @param {string} channel - Channel name.
|
|
83
|
-
* @param {Function} callback - The function to be removed from the listeners.
|
|
84
|
-
* @private
|
|
85
|
-
*/
|
|
86
|
-
private _removeListener;
|
|
87
|
-
/**
|
|
88
|
-
* @param {Function[]} listeners - List of listeners, either for the string or binary socket.
|
|
89
|
-
* @param {string} [channel=null] - Channel name of the listeners to remove. If null
|
|
90
|
-
* all the listeners are cleared.
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
private _removeAllListeners;
|
|
94
|
-
/**
|
|
95
|
-
* Add the socket to a room
|
|
96
|
-
*
|
|
97
|
-
* @param {string} roomId - Id of the room.
|
|
98
|
-
*/
|
|
99
|
-
addToRoom(roomId: string): void;
|
|
100
|
-
/**
|
|
101
|
-
* Remove the socket from a room
|
|
102
|
-
*
|
|
103
|
-
* @param {string} roomId - Id of the room.
|
|
104
|
-
*/
|
|
105
|
-
removeFromRoom(roomId: string): void;
|
|
106
|
-
/**
|
|
107
|
-
* Send messages with JSON compatible data types on a given channel.
|
|
108
|
-
*
|
|
109
|
-
* @param {string} channel - Channel name.
|
|
110
|
-
* @param {...*} args - Payload of the message. As many arguments as needed, of
|
|
111
|
-
* JSON compatible data types (i.e. string, number, boolean, object, array and null).
|
|
112
|
-
*/
|
|
113
|
-
send(channel: string, ...args: any[]): void;
|
|
114
|
-
/**
|
|
115
|
-
* Listen messages with JSON compatible data types on a given channel.
|
|
116
|
-
*
|
|
117
|
-
* @param {string} channel - Channel name.
|
|
118
|
-
* @param {Function} callback - Callback to execute when a message is received,
|
|
119
|
-
* arguments of the callback function will match the arguments sent using the
|
|
120
|
-
* {@link server.Socket#send} method.
|
|
121
|
-
*/
|
|
122
|
-
addListener(channel: string, callback: Function): void;
|
|
123
|
-
/**
|
|
124
|
-
* Remove a listener of messages with JSON compatible data types from a given channel.
|
|
125
|
-
*
|
|
126
|
-
* @param {string} channel - Channel name.
|
|
127
|
-
* @param {Function} callback - Callback to remove.
|
|
128
|
-
*/
|
|
129
|
-
removeListener(channel: string, callback: Function): void;
|
|
130
|
-
/**
|
|
131
|
-
* Remove all listeners of messages with JSON compatible data types.
|
|
132
|
-
*
|
|
133
|
-
* @param {string} channel - Channel name.
|
|
134
|
-
*/
|
|
135
|
-
removeAllListeners(channel?: string): void;
|
|
136
|
-
/**
|
|
137
|
-
* Send binary messages on a given channel.
|
|
138
|
-
*
|
|
139
|
-
* @param {string} channel - Channel name.
|
|
140
|
-
* @param {TypedArray} typedArray - Binary data to be sent.
|
|
141
|
-
*/
|
|
142
|
-
sendBinary(channel: string, typedArray: TypedArray): void;
|
|
143
|
-
/**
|
|
144
|
-
* Listen binary messages on a given channel
|
|
145
|
-
*
|
|
146
|
-
* @param {string} channel - Channel name.
|
|
147
|
-
* @param {Function} callback - Callback to execute when a message is received.
|
|
148
|
-
*/
|
|
149
|
-
addBinaryListener(channel: string, callback: Function): void;
|
|
150
|
-
/**
|
|
151
|
-
* Remove a listener of binary compatible messages from a given channel
|
|
152
|
-
*
|
|
153
|
-
* @param {string} channel - Channel name.
|
|
154
|
-
* @param {Function} callback - Callback to remove.
|
|
155
|
-
*/
|
|
156
|
-
removeBinaryListener(channel: string, callback: Function): void;
|
|
157
|
-
/**
|
|
158
|
-
* Remove all listeners of binary compatible messages on a given channel
|
|
159
|
-
*
|
|
160
|
-
* @param {string} channel - Channel of the message.
|
|
161
|
-
*/
|
|
162
|
-
removeAllBinaryListeners(channel?: string): void;
|
|
163
|
-
}
|
|
164
|
-
//# sourceMappingURL=Socket.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Socket.d.ts","sourceRoot":"","sources":["../../src/server/Socket.js"],"names":[],"mappings":";AAqBA;;;;;;;;;;;;;;;;GAgBG;AACH;IACE,8DAiIC;IAhIC;;;;;OAKG;IACH,WAAY;IAEZ;;;;;OAKG;IACH,iBAAwB;IAExB;;;;;;;OAOG;IACH,wBAAsB;IAEtB;;;;;OAKG;IACH,cAAkB;IAElB,eAAe;IACf,yBAAiC;IACjC,eAAe;IACf,yBAAiC;IACjC,eAAe;IACf,qBAAwB;IAIxB,eAAe;IACf,iBAAoB;IAsFtB;;;;;OAKG;IACH,kBAoCC;IAED;;;;;OAKG;IACH,cAOC;IAED;;;;;OAKG;IACH,qBAOC;IAED;;;;;OAKG;IACH,wBASC;IAED;;;;;OAKG;IACH,4BAMC;IAED;;;;OAIG;IACH,kBAFW,MAAM,QAShB;IAED;;;;OAIG;IACH,uBAFW,MAAM,QAOhB;IAED;;;;;;OAMG;IACH,cAJW,MAAM,wBAkBhB;IAED;;;;;;;OAOG;IACH,qBALW,MAAM,4BAOhB;IAED;;;;;OAKG;IACH,wBAHW,MAAM,4BAKhB;IAED;;;;OAIG;IACH,6BAFW,MAAM,QAIhB;IAED;;;;;OAKG;IACH,oBAHW,MAAM,gCAWhB;IAED;;;;;OAKG;IACH,2BAHW,MAAM,4BAKhB;IAED;;;;;OAKG;IACH,8BAHW,MAAM,4BAKhB;IAED;;;;OAIG;IACH,mCAFW,MAAM,QAIhB;CACF"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export default Sockets;
|
|
2
|
-
/**
|
|
3
|
-
* Manager all {@link server.Socket} instances.
|
|
4
|
-
*
|
|
5
|
-
* Most of the time, you shouldn't have to use this class instance directely, but
|
|
6
|
-
* it could be usefull in some situations, for broadcasting messages, creating rooms, etc.
|
|
7
|
-
*
|
|
8
|
-
* @memberof server
|
|
9
|
-
*/
|
|
10
|
-
declare class Sockets {
|
|
11
|
-
/** @private */
|
|
12
|
-
private _wss;
|
|
13
|
-
/** @private */
|
|
14
|
-
private _rooms;
|
|
15
|
-
/** @private */
|
|
16
|
-
private _initializationCache;
|
|
17
|
-
/** @private */
|
|
18
|
-
private _latencyStatsWorker;
|
|
19
|
-
/** @private */
|
|
20
|
-
private _auditState;
|
|
21
|
-
/** @private */
|
|
22
|
-
private _DEBUG_PREVENT_HEARTBEAT;
|
|
23
|
-
/**
|
|
24
|
-
* Initialize sockets, all sockets are added to two rooms by default:
|
|
25
|
-
* - to the room corresponding to the client `role`
|
|
26
|
-
* - to the '*' room that holds all connected sockets
|
|
27
|
-
*
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
private start;
|
|
31
|
-
/**
|
|
32
|
-
* Terminate all existing sockets
|
|
33
|
-
*
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
|
-
private terminate;
|
|
37
|
-
/** @private */
|
|
38
|
-
private _broadcast;
|
|
39
|
-
/**
|
|
40
|
-
* Add a socket to a room
|
|
41
|
-
*
|
|
42
|
-
* @param {server.Socket} socket - Socket to add to the room.
|
|
43
|
-
* @param {String} roomId - Id of the room.
|
|
44
|
-
*/
|
|
45
|
-
addToRoom(socket: server.Socket, roomId: string): void;
|
|
46
|
-
/**
|
|
47
|
-
* Remove a socket from a room
|
|
48
|
-
*
|
|
49
|
-
* @param {server.Socket} socket - Socket to remove from the room.
|
|
50
|
-
* @param {String} roomId - Id of the room.
|
|
51
|
-
*/
|
|
52
|
-
removeFromRoom(socket: server.Socket, roomId: string): void;
|
|
53
|
-
/**
|
|
54
|
-
* Send a message of JSON compatible data types to all client of given room(s).
|
|
55
|
-
* If no room is specified, the message is sent to all clients.
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @param {String|Array} roomsIds - Ids of the rooms that must receive
|
|
59
|
-
* the message. If `null` the message is sent to all clients.
|
|
60
|
-
* @param {server.Socket} excludeSocket - Optionnal socket to ignore when
|
|
61
|
-
* broadcasting the message, typically the client at the origin of the message.
|
|
62
|
-
* @param {String} channel - Channel name.
|
|
63
|
-
* @param {...*} args - Payload of the message. As many arguments as needed, of
|
|
64
|
-
* JSON compatible data types (i.e. string, number, boolean, object, array and null).
|
|
65
|
-
*/
|
|
66
|
-
broadcast(roomIds: any, excludeSocket: server.Socket, channel: string, ...args: any[]): void;
|
|
67
|
-
/**
|
|
68
|
-
* Send a binary message to all client of given room(s). If no room is specified
|
|
69
|
-
* specified, the message is sent to all clients.
|
|
70
|
-
*
|
|
71
|
-
* @param {String|Array} roomsIds - Ids of the rooms that must receive
|
|
72
|
-
* the message. If `null` the message is sent to all clients.
|
|
73
|
-
* @param {server.Socket} excludeSocket - Optionnal socket to ignore when
|
|
74
|
-
* broadcasting the message, typically the client at the origin of the message.
|
|
75
|
-
* @param {string} channel - Channel name.
|
|
76
|
-
* @param {TypedArray} typedArray - Binary data to be sent.
|
|
77
|
-
*/
|
|
78
|
-
broadcastBinary(roomIds: any, excludeSocket: server.Socket, channel: string, typedArray: TypedArray): void;
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=Sockets.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Sockets.d.ts","sourceRoot":"","sources":["../../src/server/Sockets.js"],"names":[],"mappings":";AAUA;;;;;;;GAOG;AACH;IAEI,eAAe;IACf,aAAgB;IAChB,eAAe;IACf,eAAuB;IAGvB,eAAe;IACf,6BAAqC;IAErC,eAAe;IACf,4BAA+B;IAC/B,eAAe;IACf,oBAAuB;IAEvB,eAAe;IACf,iCAAqC;IAGvC;;;;;;OAMG;IACH,cA8EC;IAED;;;;OAIG;IACH,kBAMC;IAED,eAAe;IACf,mBA8BC;IAED;;;;;OAKG;IACH,uDAEC;IAED;;;;;OAKG;IACH,4DAEC;IAED;;;;;;;;;;;;OAYG;IACH,6FAEC;IAED;;;;;;;;;;OAUG;IACH,qEAHW,MAAM,gCAKhB;CACF"}
|