@arcblock/ws 1.18.74 → 1.18.76

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,8 +13,8 @@ const sleep = (timeout) =>
13
13
  setTimeout(resolve, timeout);
14
14
  });
15
15
 
16
- const reply = ({ socket, topic, event, data, status = 'ok', ref = '', joinRef = '' }) => {
17
- if (socket.readyState === WebSocket.OPEN && socket.channel[topic]) {
16
+ const reply = ({ socket, topic, event, data = {}, status = 'ok', ref = '', joinRef = '' }) => {
17
+ if (socket.readyState === WebSocket.OPEN) {
18
18
  const res = JSON.stringify([joinRef, ref, topic, event, { status, response: data }]);
19
19
  socket.send(res);
20
20
  }
@@ -328,13 +328,7 @@ class WsServer extends EventEmitter {
328
328
  }
329
329
  this.topics[topic].add(socket);
330
330
 
331
- reply({
332
- socket,
333
- topic,
334
- event: `chan_reply_${ref}`,
335
- ref,
336
- joinRef,
337
- });
331
+ reply({ socket, topic, event: `chan_reply_${ref}`, ref, joinRef });
338
332
  this.emit('channel.join', { socket, topic, event, payload });
339
333
 
340
334
  // post hook
@@ -371,13 +365,7 @@ class WsServer extends EventEmitter {
371
365
 
372
366
  // leave
373
367
  this._leaveChannel(socket, topic);
374
- reply({
375
- socket,
376
- topic,
377
- event: `chan_reply_${ref}`,
378
- ref,
379
- joinRef,
380
- });
368
+ reply({ socket, topic, event: `chan_reply_${ref}`, ref, joinRef });
381
369
 
382
370
  // post hook
383
371
  try {
@@ -410,14 +398,7 @@ class WsServer extends EventEmitter {
410
398
  return;
411
399
  }
412
400
 
413
- reply({
414
- socket,
415
- topic,
416
- event: `chan_reply_${ref}`,
417
- data: {},
418
- ref,
419
- joinRef,
420
- });
401
+ reply({ socket, topic, event: `chan_reply_${ref}`, ref, joinRef });
421
402
  });
422
403
 
423
404
  socket.on('close', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ws",
3
- "version": "1.18.74",
3
+ "version": "1.18.76",
4
4
  "description": "OCAP Chain websocket server and client",
5
5
  "keywords": [
6
6
  "websocket"
@@ -34,7 +34,7 @@
34
34
  "url": "https://github.com/ArcBlock/asset-chain/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@arcblock/event-hub": "1.18.74",
37
+ "@arcblock/event-hub": "1.18.76",
38
38
  "debug": "^4.3.4",
39
39
  "eventemitter3": "^4.0.7",
40
40
  "lodash": "^4.17.21",
@@ -45,5 +45,5 @@
45
45
  "devDependencies": {
46
46
  "get-port": "^5.1.1"
47
47
  },
48
- "gitHead": "87ab9471b0de6669100b56138193ec1705a97fb2"
48
+ "gitHead": "5a69ad290c7b3e1c0b498e7f733a317ea400a578"
49
49
  }