@cuecue/socketio 0.0.39 → 0.0.42

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/dist/index.js +16 -13
  2. 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 io = require('socket.io');
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 = io__default["default"](ioOptions);
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
 
@@ -265,9 +271,6 @@ class ServerInput extends BaseServer {
265
271
  } = {}) {
266
272
  super({
267
273
  namespace: process.env.SOCKETIO_INPUT_NAMESPACE || null,
268
- cors: {
269
- origin: 'http://localhost:5000'
270
- },
271
274
  ...opts
272
275
  });
273
276
  this.onConnection = this.onConnection.bind(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuecue/socketio",
3
- "version": "0.0.39",
3
+ "version": "0.0.42",
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.39",
43
+ "@cuecue/core": "^0.0.42",
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": "283b8f467105917c14cab75611d34a95d4c2676f"
53
+ "gitHead": "ce63758c17a7b670e6684e3dee3091a07b132522"
54
54
  }