@cuecue/socketio 0.0.30 → 0.0.34
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 +13 -41
- 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');
|
|
@@ -225,17 +226,22 @@ class BaseServer extends core.BasePlugin {
|
|
|
225
226
|
async createServer() {
|
|
226
227
|
const {
|
|
227
228
|
server,
|
|
228
|
-
port
|
|
229
|
+
port,
|
|
230
|
+
cors,
|
|
231
|
+
namespace
|
|
229
232
|
} = this.options;
|
|
230
|
-
const ioOptions = {
|
|
233
|
+
const ioOptions = {
|
|
234
|
+
cors
|
|
235
|
+
};
|
|
231
236
|
this.io = io__default["default"](ioOptions);
|
|
232
|
-
this.io.
|
|
237
|
+
this.namespace = namespace !== null ? this.io.of(namespace) : this.io;
|
|
238
|
+
this.namespace.on('connection', this.onConnection);
|
|
233
239
|
this.io.listen(server || port);
|
|
234
240
|
return Promise.resolve();
|
|
235
241
|
}
|
|
236
242
|
|
|
237
243
|
async closeServer() {
|
|
238
|
-
this.
|
|
244
|
+
this.namespace.off('connection', this.onConnection);
|
|
239
245
|
return new Promise(resolve => {
|
|
240
246
|
this.io.close(() => {
|
|
241
247
|
resolve();
|
|
@@ -269,34 +275,8 @@ class ServerInput extends BaseServer {
|
|
|
269
275
|
return this;
|
|
270
276
|
}
|
|
271
277
|
|
|
272
|
-
async
|
|
273
|
-
await super.
|
|
274
|
-
const {
|
|
275
|
-
namespace
|
|
276
|
-
} = this.namespace;
|
|
277
|
-
|
|
278
|
-
if (namespace !== null) {
|
|
279
|
-
this.io.of(namespace).on('connection', this.onSocketConnection);
|
|
280
|
-
} else {
|
|
281
|
-
this.io.on('connection', this.onSocketConnection);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
async onDestroy() {
|
|
286
|
-
const {
|
|
287
|
-
namespace
|
|
288
|
-
} = this.namespace;
|
|
289
|
-
|
|
290
|
-
if (namespace !== null) {
|
|
291
|
-
this.io.of(namespace).off('connection', this.onSocketConnection);
|
|
292
|
-
} else {
|
|
293
|
-
this.io.off('connection', this.onSocketConnection);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
await super.onDestroy();
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
async onSocketConnection(socket) {
|
|
278
|
+
async onConnection(socket) {
|
|
279
|
+
await super.onConnection(socket);
|
|
300
280
|
socket.on('message', this.onMessage);
|
|
301
281
|
}
|
|
302
282
|
|
|
@@ -396,15 +376,7 @@ class ServerOutput extends BaseServer {
|
|
|
396
376
|
|
|
397
377
|
async send(...args) {
|
|
398
378
|
this.debug('send: %o', args);
|
|
399
|
-
|
|
400
|
-
namespace = null
|
|
401
|
-
} = this.options;
|
|
402
|
-
|
|
403
|
-
if (namespace !== null) {
|
|
404
|
-
return this.sendToNamespace(namespace, ...args);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
this.io.send(...args);
|
|
379
|
+
this.namespace.send(...args);
|
|
408
380
|
return Promise.resolve();
|
|
409
381
|
}
|
|
410
382
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuecue/socketio",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
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.34",
|
|
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": "16ca4a1b0df3688d44cf6f46354bfbc488fad09f"
|
|
54
54
|
}
|