@cuecue/socketio 0.0.38 → 0.0.41
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 +16 -10
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6,13 +6,12 @@ var createDebug = require('debug');
|
|
|
6
6
|
var isArray = require('lodash/isArray');
|
|
7
7
|
var core = require('@cuecue/core');
|
|
8
8
|
var socket_ioClient = require('socket.io-client');
|
|
9
|
-
var
|
|
9
|
+
var socket_io = require('socket.io');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
12
|
|
|
13
13
|
var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
14
14
|
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
|
|
15
|
-
var io__default = /*#__PURE__*/_interopDefaultLegacy(io);
|
|
16
15
|
|
|
17
16
|
class Base extends core.BasePlugin {
|
|
18
17
|
constructor({
|
|
@@ -22,6 +21,7 @@ class Base extends core.BasePlugin {
|
|
|
22
21
|
super({
|
|
23
22
|
host: process.env.SOCKETIO_HOST || 'localhost',
|
|
24
23
|
namespace: process.env.SOCKETIO_NAMESPACE || null,
|
|
24
|
+
path: process.env.SOCKETIO_PATH || null,
|
|
25
25
|
...opts
|
|
26
26
|
});
|
|
27
27
|
this.onConnect = this.onConnect.bind(this);
|
|
@@ -42,9 +42,12 @@ class Base extends core.BasePlugin {
|
|
|
42
42
|
async connectSocket() {
|
|
43
43
|
const {
|
|
44
44
|
host,
|
|
45
|
-
namespace
|
|
45
|
+
namespace = null,
|
|
46
|
+
path = null
|
|
46
47
|
} = this.options;
|
|
47
|
-
this.socket = socket_ioClient.io(namespace !== null ? host.replace(/\/?$/, `/${namespace.replace(/^\//, '')}`) : host
|
|
48
|
+
this.socket = socket_ioClient.io(namespace !== null ? host.replace(/\/?$/, `/${namespace.replace(/^\//, '')}`) : host, path !== null ? {
|
|
49
|
+
path
|
|
50
|
+
} : null);
|
|
48
51
|
this.socket.on('connect', this.onConnect);
|
|
49
52
|
return Promise.resolve();
|
|
50
53
|
}
|
|
@@ -58,9 +61,10 @@ class Base extends core.BasePlugin {
|
|
|
58
61
|
onConnect() {
|
|
59
62
|
const {
|
|
60
63
|
host,
|
|
61
|
-
namespace
|
|
64
|
+
namespace = null,
|
|
65
|
+
path = null
|
|
62
66
|
} = this.options;
|
|
63
|
-
this.debug('Connected on %s/%s', host, namespace || '');
|
|
67
|
+
this.debug('Connected on %s/%s', host, namespace || '', path || '');
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
}
|
|
@@ -205,6 +209,7 @@ class BaseServer extends core.BasePlugin {
|
|
|
205
209
|
namespace: process.env.SOCKETIO_NAMESPACE || null,
|
|
206
210
|
transports: ['websocket', 'polling'],
|
|
207
211
|
server: null,
|
|
212
|
+
path: '/socket.io/',
|
|
208
213
|
...opts
|
|
209
214
|
});
|
|
210
215
|
this.io = null;
|
|
@@ -230,16 +235,17 @@ class BaseServer extends core.BasePlugin {
|
|
|
230
235
|
port,
|
|
231
236
|
cors,
|
|
232
237
|
transports,
|
|
233
|
-
namespace
|
|
238
|
+
namespace,
|
|
239
|
+
path
|
|
234
240
|
} = this.options;
|
|
235
241
|
const ioOptions = {
|
|
236
242
|
transports,
|
|
237
|
-
cors
|
|
243
|
+
cors,
|
|
244
|
+
path
|
|
238
245
|
};
|
|
239
|
-
this.io =
|
|
246
|
+
this.io = new socket_io.Server(server || port, ioOptions);
|
|
240
247
|
this.namespace = namespace !== null ? this.io.of(namespace) : this.io;
|
|
241
248
|
this.namespace.on('connection', this.onConnection);
|
|
242
|
-
this.io.listen(server || port);
|
|
243
249
|
return Promise.resolve();
|
|
244
250
|
}
|
|
245
251
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuecue/socketio",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
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.41",
|
|
44
44
|
"debug": "^4.3.1",
|
|
45
45
|
"lodash": "^4.17.21",
|
|
46
46
|
"socket.io": "^4.1.2",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "54c4e793bd8a40b499eb535e7b5bd201109a3bae"
|
|
54
54
|
}
|