@nxtedition/deepstream.io-client-js 24.1.5 → 24.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "24.1.5",
3
+ "version": "24.1.7",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -136,6 +136,13 @@ Connection.prototype.send = function (message) {
136
136
  return false
137
137
  }
138
138
 
139
+ if (this._endpoint._socket && !this._endpoint._socket.writableCorked) {
140
+ this._endpoint._socket.cork()
141
+ queueMicrotask(() => {
142
+ this._endpoint._socket.uncork()
143
+ })
144
+ }
145
+
139
146
  this.emit('send', message)
140
147
  this._endpoint.send(message)
141
148
 
@@ -325,6 +332,7 @@ Connection.prototype._setState = function (state) {
325
332
  this.emit(C.EVENT.CONNECTED, true)
326
333
  this._client.emit(C.EVENT.CONNECTED, true)
327
334
  } else if (state === C.CONNECTION_STATE.RECONNECTING || state === C.CONNECTION_STATE.CLOSED) {
335
+ this._recvQueue = new FixedQueue()
328
336
  this.emit(C.EVENT.CONNECTED, false)
329
337
  this._client.emit(C.EVENT.CONNECTED, false)
330
338
  }
@@ -36,13 +36,10 @@ class Listener {
36
36
  this._handler = handler
37
37
  this._client = this._handler._client
38
38
  this._connection = this._handler._connection
39
+ this._listening = false
39
40
  this._subscriptions = new Map()
40
41
 
41
- this._$onConnectionStateChange()
42
- }
43
-
44
- get connected() {
45
- return this._connection.connected
42
+ this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN, [this._pattern, 'U'])
46
43
  }
47
44
 
48
45
  get stats() {
@@ -53,23 +50,9 @@ class Listener {
53
50
 
54
51
  _$destroy() {
55
52
  this._reset()
56
-
57
- if (this.connected) {
58
- this._connection.sendMsg(this._topic, C.ACTIONS.UNLISTEN, [this._pattern])
59
- }
60
53
  }
61
54
 
62
55
  _$onMessage(message) {
63
- if (!this.connected) {
64
- this._client._$onError(
65
- C.TOPIC.RECORD,
66
- C.EVENT.NOT_CONNECTED,
67
- new Error('received message while not connected'),
68
- message
69
- )
70
- return
71
- }
72
-
73
56
  const name = message.data[1]
74
57
 
75
58
  if (message.action === C.ACTIONS.LISTEN_ACCEPT) {
@@ -106,7 +89,6 @@ class Listener {
106
89
  this._subscriptions.set(name, subscription)
107
90
  } else {
108
91
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
109
- this._subscriptions.delete(name)
110
92
  }
111
93
  } else if (message.action === C.ACTIONS.LISTEN_REJECT) {
112
94
  const subscription = this._subscriptions.get(name)
@@ -123,8 +105,8 @@ class Listener {
123
105
  return true
124
106
  }
125
107
 
126
- _$onConnectionStateChange() {
127
- if (this.connected) {
108
+ _$onConnectionStateChange(connected) {
109
+ if (connected) {
128
110
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN, [this._pattern, 'U'])
129
111
  } else {
130
112
  this._reset()
@@ -137,9 +119,11 @@ class Listener {
137
119
 
138
120
  _reset() {
139
121
  for (const subscription of this._subscriptions.values()) {
140
- subscription?.unsubscribe()
122
+ subscription.unsubscribe()
141
123
  }
142
124
  this._subscriptions.clear()
125
+
126
+ this._connection.sendMsg(this._topic, C.ACTIONS.UNLISTEN, [this._pattern])
143
127
  }
144
128
  }
145
129