@nxtedition/deepstream.io-client-js 24.0.8 → 24.0.10
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
package/src/client.js
CHANGED
|
@@ -91,7 +91,8 @@ Client.prototype._$onMessage = function (message) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
Client.prototype._$onError = function (topic, event, msgOrError, data) {
|
|
94
|
-
const error =
|
|
94
|
+
const error =
|
|
95
|
+
msgOrError && msgOrError.message ? msgOrError : new Error(msgOrError || 'unknown error')
|
|
95
96
|
error.topic = topic
|
|
96
97
|
error.event = event
|
|
97
98
|
error.data = data
|
package/src/default-options.js
CHANGED
|
@@ -158,7 +158,15 @@ class RecordHandler {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
get stats() {
|
|
161
|
-
|
|
161
|
+
let subscriptions = 0
|
|
162
|
+
for (const listener of this._listeners.values()) {
|
|
163
|
+
subscriptions += listener.subscriptions ?? 0
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
...this._stats,
|
|
168
|
+
subscriptions,
|
|
169
|
+
}
|
|
162
170
|
}
|
|
163
171
|
|
|
164
172
|
/**
|
|
@@ -9,7 +9,7 @@ class Listener {
|
|
|
9
9
|
this._handler = handler
|
|
10
10
|
this._client = this._handler._client
|
|
11
11
|
this._connection = this._handler._connection
|
|
12
|
-
this.
|
|
12
|
+
this._subscriptions = new Map()
|
|
13
13
|
this._recursive = recursive
|
|
14
14
|
this._stringify = stringify || JSON.stringify
|
|
15
15
|
|
|
@@ -20,6 +20,12 @@ class Listener {
|
|
|
20
20
|
return this._client.getConnectionState() === C.CONNECTION_STATE.OPEN
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
get stats() {
|
|
24
|
+
return {
|
|
25
|
+
subscriptions: this._subscriptions.size,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
_$destroy() {
|
|
24
30
|
this._reset()
|
|
25
31
|
|
|
@@ -42,7 +48,7 @@ class Listener {
|
|
|
42
48
|
const name = message.data[1]
|
|
43
49
|
|
|
44
50
|
if (message.action === C.ACTIONS.SUBSCRIPTION_FOR_PATTERN_FOUND) {
|
|
45
|
-
if (this.
|
|
51
|
+
if (this._subscriptions.has(name)) {
|
|
46
52
|
this._error(name, 'invalid add: listener exists')
|
|
47
53
|
return
|
|
48
54
|
}
|
|
@@ -175,9 +181,9 @@ class Listener {
|
|
|
175
181
|
|
|
176
182
|
provider.start()
|
|
177
183
|
|
|
178
|
-
this.
|
|
184
|
+
this._subscriptions.set(provider.name, provider)
|
|
179
185
|
} else if (message.action === C.ACTIONS.LISTEN_ACCEPT) {
|
|
180
|
-
const provider = this.
|
|
186
|
+
const provider = this._subscriptions.get(name)
|
|
181
187
|
if (!provider?.value$) {
|
|
182
188
|
return
|
|
183
189
|
}
|
|
@@ -189,13 +195,13 @@ class Listener {
|
|
|
189
195
|
provider.valueSubscription = provider.value$.subscribe(provider.observer)
|
|
190
196
|
}
|
|
191
197
|
} else if (message.action === C.ACTIONS.SUBSCRIPTION_FOR_PATTERN_REMOVED) {
|
|
192
|
-
const provider = this.
|
|
198
|
+
const provider = this._subscriptions.get(name)
|
|
193
199
|
|
|
194
200
|
if (!provider) {
|
|
195
201
|
this._error(name, 'invalid remove: listener missing')
|
|
196
202
|
} else {
|
|
197
203
|
provider.stop()
|
|
198
|
-
this.
|
|
204
|
+
this._subscriptions.delete(provider.name)
|
|
199
205
|
}
|
|
200
206
|
} else {
|
|
201
207
|
return false
|
|
@@ -216,10 +222,10 @@ class Listener {
|
|
|
216
222
|
}
|
|
217
223
|
|
|
218
224
|
_reset() {
|
|
219
|
-
for (const provider of this.
|
|
225
|
+
for (const provider of this._subscriptions.values()) {
|
|
220
226
|
provider.stop()
|
|
221
227
|
}
|
|
222
|
-
this.
|
|
228
|
+
this._subscriptions.clear()
|
|
223
229
|
}
|
|
224
230
|
}
|
|
225
231
|
|