@cuecue/socketio 0.0.31 → 0.0.32
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/dist/index.js +10 -33
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -207,6 +207,7 @@ class BaseServer extends core.BasePlugin {
|
|
|
207
207
|
...opts
|
|
208
208
|
});
|
|
209
209
|
this.io = null;
|
|
210
|
+
this.namespace - null;
|
|
210
211
|
this.onConnection = this.onConnection.bind(this);
|
|
211
212
|
this.commands = commands;
|
|
212
213
|
this.debug = createDebug__default["default"]('cuecue:socketio');
|
|
@@ -226,19 +227,21 @@ class BaseServer extends core.BasePlugin {
|
|
|
226
227
|
const {
|
|
227
228
|
server,
|
|
228
229
|
port,
|
|
229
|
-
cors
|
|
230
|
+
cors,
|
|
231
|
+
namespace
|
|
230
232
|
} = this.options;
|
|
231
233
|
const ioOptions = {
|
|
232
234
|
cors
|
|
233
235
|
};
|
|
234
236
|
this.io = io__default["default"](ioOptions);
|
|
235
|
-
this.io.
|
|
237
|
+
this.namespace = namespace !== null ? this.io.of(namespace) : this.io;
|
|
238
|
+
this.namespace.on('connection', this.onConnection);
|
|
236
239
|
this.io.listen(server || port);
|
|
237
240
|
return Promise.resolve();
|
|
238
241
|
}
|
|
239
242
|
|
|
240
243
|
async closeServer() {
|
|
241
|
-
this.
|
|
244
|
+
this.namespace.off('connection', this.onConnection);
|
|
242
245
|
return new Promise(resolve => {
|
|
243
246
|
this.io.close(() => {
|
|
244
247
|
resolve();
|
|
@@ -272,34 +275,8 @@ class ServerInput extends BaseServer {
|
|
|
272
275
|
return this;
|
|
273
276
|
}
|
|
274
277
|
|
|
275
|
-
async
|
|
276
|
-
await super.
|
|
277
|
-
const {
|
|
278
|
-
namespace
|
|
279
|
-
} = this.namespace;
|
|
280
|
-
|
|
281
|
-
if (namespace !== null) {
|
|
282
|
-
this.io.of(namespace).on('connection', this.onSocketConnection);
|
|
283
|
-
} else {
|
|
284
|
-
this.io.on('connection', this.onSocketConnection);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
async onDestroy() {
|
|
289
|
-
const {
|
|
290
|
-
namespace
|
|
291
|
-
} = this.namespace;
|
|
292
|
-
|
|
293
|
-
if (namespace !== null) {
|
|
294
|
-
this.io.of(namespace).off('connection', this.onSocketConnection);
|
|
295
|
-
} else {
|
|
296
|
-
this.io.off('connection', this.onSocketConnection);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
await super.onDestroy();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
async onSocketConnection(socket) {
|
|
278
|
+
async onConnection(socket) {
|
|
279
|
+
await super.onConnection(socket);
|
|
303
280
|
socket.on('message', this.onMessage);
|
|
304
281
|
}
|
|
305
282
|
|
|
@@ -407,13 +384,13 @@ class ServerOutput extends BaseServer {
|
|
|
407
384
|
return this.sendToNamespace(namespace, ...args);
|
|
408
385
|
}
|
|
409
386
|
|
|
410
|
-
this.
|
|
387
|
+
this.namespace.send(...args);
|
|
411
388
|
return Promise.resolve();
|
|
412
389
|
}
|
|
413
390
|
|
|
414
391
|
async sendToNamespace(namespace, ...args) {
|
|
415
392
|
this.debug('send: %o', args);
|
|
416
|
-
this.
|
|
393
|
+
this.namespace.of(namespace).send(...args);
|
|
417
394
|
return Promise.resolve();
|
|
418
395
|
}
|
|
419
396
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuecue/socketio",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/runtime": "^7.12.5",
|
|
43
|
-
"@cuecue/core": "^0.0.
|
|
43
|
+
"@cuecue/core": "^0.0.32",
|
|
44
44
|
"debug": "^4.3.1",
|
|
45
45
|
"lodash": "^4.17.20",
|
|
46
46
|
"socket.io": "^4.1.2",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "ea2dab28c212c792af3cf1da9ef5e6603c408207"
|
|
54
54
|
}
|