@ircam/comote-helpers 1.5.5 → 1.5.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.js +7 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ircam/comote-helpers",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "Server component & utilities for the CoMote application",
5
5
  "authors": [
6
6
  "Benjamin.Matuszewski@ircam.fr",
package/src/server.js CHANGED
@@ -4,8 +4,6 @@ import { Server as OscServer } from 'node-osc';
4
4
  import cloneDeep from 'clone-deep';
5
5
  import assignDeep from 'assign-deep';
6
6
 
7
- console.log(WebSocket);
8
-
9
7
  /**
10
8
  * @typedef {Object} CoMoteConfig
11
9
  * @property {String} id - id of the client CoMote
@@ -27,7 +25,7 @@ console.log(WebSocket);
27
25
  *
28
26
  * @param {CoMoteConfig} config - CoMote configuration
29
27
  * @param {Object} options - options
30
- * @param {Object} [options.verbose=false] - logs debug informations
28
+ * @param {Object} [options.verbose=false] - logs debug information
31
29
  */
32
30
  export class Server {
33
31
  constructor(config, options) {
@@ -39,7 +37,6 @@ export class Server {
39
37
  interval: null,
40
38
  osc: null,
41
39
  ws: null,
42
- verbose: false,
43
40
  }, config));
44
41
 
45
42
  this._verbose = !!options.verbose;
@@ -61,7 +58,7 @@ export class Server {
61
58
  let oscPromise = true;
62
59
 
63
60
  if (this.config.ws !== null) {
64
- const { hostname, port } = this.config.ws;
61
+ const { port } = this.config.ws;
65
62
 
66
63
  if (!Number.isInteger(port)) {
67
64
  throw new Error(`Invalid port "${port}" for WebSocket server`);
@@ -72,8 +69,7 @@ export class Server {
72
69
  }
73
70
 
74
71
  this._websocketServer = new WebSocketServer({ port });
75
- this._websocketServer.on('connection', (socket, request) => {
76
- // const ip = request.socket.remoteAddress;
72
+ this._websocketServer.on('connection', (socket, _request) => {
77
73
  socket.on('message', (data, isBinary) => {
78
74
  if (isBinary) {
79
75
  // @todo
@@ -85,15 +81,13 @@ export class Server {
85
81
  console.log(`> CoMote: new WebSocket message`, data);
86
82
  }
87
83
 
88
- // console.log(data);
89
- // console.log(this._wsListeners.size);
90
84
  this._wsListeners.forEach(listener => listener(data));
91
85
  }
92
86
  }
93
87
  });
94
88
 
95
89
  // When a socket closes, or disconnects, remove it from the array.
96
- socket.on('close', (code, data) => {
90
+ socket.on('close', (_code, _data) => {
97
91
  if (this._verbose) {
98
92
  console.log('> CoMote: closed socket connection');
99
93
  }
@@ -117,7 +111,7 @@ export class Server {
117
111
  }
118
112
 
119
113
  if (this.config.osc !== null) {
120
- const { hostname, port } = this.config.osc;
114
+ let { hostname, port } = this.config.osc;
121
115
 
122
116
  if (!Number.isInteger(port)) {
123
117
  throw new Error(`Invalid port "${port}" for OSC server`);
@@ -173,7 +167,7 @@ export class Server {
173
167
  }
174
168
 
175
169
  /**
176
- * Add a listener for incomming WebSocket message
170
+ * Add a listener for incoming WebSocket message
177
171
  */
178
172
  addWsListener(callback) {
179
173
  this._wsListeners.add(callback);
@@ -189,7 +183,7 @@ export class Server {
189
183
  }
190
184
 
191
185
  /**
192
- * Add a listener for incomming OSC message
186
+ * Add a listener for incoming OSC message
193
187
  */
194
188
  addOscListener(callback) {
195
189
  this._oscListeners.add(callback);