@nxtedition/deepstream.io-client-js 24.2.9 → 24.2.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 +1 -1
- package/src/message/connection.js +18 -19
- package/src/record/record-handler.js +1 -14
- package/src/record/record.js +4 -1
package/package.json
CHANGED
|
@@ -101,8 +101,7 @@ Connection.prototype.close = function () {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
Connection.prototype._createEndpoint = function () {
|
|
104
|
-
|
|
105
|
-
if (NodeWebSocket) {
|
|
104
|
+
if (utils.isNode) {
|
|
106
105
|
this._endpoint = new NodeWebSocket(this._url, {
|
|
107
106
|
generateMask() {},
|
|
108
107
|
})
|
|
@@ -110,16 +109,16 @@ Connection.prototype._createEndpoint = function () {
|
|
|
110
109
|
this._endpoint = new BrowserWebSocket(this._url)
|
|
111
110
|
this._endpoint.binaryType = 'arraybuffer'
|
|
112
111
|
}
|
|
113
|
-
|
|
114
|
-
this._endpoint.onmessage = ({ data }) => {
|
|
115
|
-
this._onMessage(typeof data === 'string' ? data : decoder.decode(data))
|
|
116
|
-
}
|
|
117
|
-
|
|
118
112
|
this._corked = false
|
|
119
113
|
|
|
120
114
|
this._endpoint.onopen = this._onOpen.bind(this)
|
|
121
115
|
this._endpoint.onerror = this._onError.bind(this)
|
|
122
116
|
this._endpoint.onclose = this._onClose.bind(this)
|
|
117
|
+
|
|
118
|
+
const decoder = new TextDecoder()
|
|
119
|
+
this._endpoint.onmessage = ({ data }) => {
|
|
120
|
+
this._onMessage(typeof data === 'string' ? data : decoder.decode(data))
|
|
121
|
+
}
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
Connection.prototype.send = function (message) {
|
|
@@ -255,20 +254,20 @@ Connection.prototype._recvMessages = function (deadline) {
|
|
|
255
254
|
continue
|
|
256
255
|
}
|
|
257
256
|
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
if (this._logger) {
|
|
258
|
+
this._logger.trace(message, 'receive')
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
messageParser.parseMessage(message, this._client, this._message)
|
|
260
262
|
|
|
261
|
-
|
|
263
|
+
this.emit('recv', this._message)
|
|
262
264
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
} catch (err) {
|
|
271
|
-
this._onError(err)
|
|
265
|
+
if (this._message.topic === C.TOPIC.CONNECTION) {
|
|
266
|
+
this._handleConnectionResponse(this._message)
|
|
267
|
+
} else if (this._message.topic === C.TOPIC.AUTH) {
|
|
268
|
+
this._handleAuthResponse(this._message)
|
|
269
|
+
} else {
|
|
270
|
+
this._client._$onMessage(this._message)
|
|
272
271
|
}
|
|
273
272
|
}
|
|
274
273
|
|
|
@@ -97,19 +97,11 @@ class RecordHandler {
|
|
|
97
97
|
this._connection = connection
|
|
98
98
|
this._client = client
|
|
99
99
|
this._records = new Map()
|
|
100
|
-
this._cache = new Map()
|
|
101
100
|
this._listeners = new Map()
|
|
102
101
|
this._pruning = new Set()
|
|
103
102
|
this._patching = new Map()
|
|
104
103
|
this._updating = new Map()
|
|
105
104
|
|
|
106
|
-
this._registry = new FinalizationRegistry((name) => {
|
|
107
|
-
const entry = this._cache.get(name)
|
|
108
|
-
if (entry && entry.deref && entry.deref() === undefined) {
|
|
109
|
-
this._cache.delete(name)
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
|
|
113
105
|
this._connected = 0
|
|
114
106
|
this._stats = {
|
|
115
107
|
updating: 0,
|
|
@@ -142,11 +134,6 @@ class RecordHandler {
|
|
|
142
134
|
for (const rec of pruning) {
|
|
143
135
|
rec._$dispose()
|
|
144
136
|
this._records.delete(rec.name)
|
|
145
|
-
|
|
146
|
-
if (!this._cache.has(rec.name)) {
|
|
147
|
-
this._cache.set(rec.name, new WeakRef(rec))
|
|
148
|
-
this._registry.register(rec, rec.name)
|
|
149
|
-
}
|
|
150
137
|
}
|
|
151
138
|
|
|
152
139
|
this._stats.pruning -= pruning.size
|
|
@@ -232,7 +219,7 @@ class RecordHandler {
|
|
|
232
219
|
let record = this._records.get(name)
|
|
233
220
|
|
|
234
221
|
if (!record) {
|
|
235
|
-
record =
|
|
222
|
+
record = new Record(name, this)
|
|
236
223
|
this._stats.records += 1
|
|
237
224
|
this._stats.created += 1
|
|
238
225
|
this._records.set(name, record)
|
package/src/record/record.js
CHANGED
|
@@ -11,7 +11,10 @@ class Record {
|
|
|
11
11
|
static STATE = C.RECORD_STATE
|
|
12
12
|
|
|
13
13
|
constructor(name, handler) {
|
|
14
|
+
const connection = handler._connection
|
|
15
|
+
|
|
14
16
|
this._handler = handler
|
|
17
|
+
|
|
15
18
|
this._name = name
|
|
16
19
|
this._version = ''
|
|
17
20
|
this._data = jsonPath.EMPTY
|
|
@@ -21,7 +24,7 @@ class Record {
|
|
|
21
24
|
this._emitting = false
|
|
22
25
|
/** @type Map? */ this._updating = null
|
|
23
26
|
/** @type Array? */ this._patching = null
|
|
24
|
-
this._subscribed =
|
|
27
|
+
this._subscribed = connection.sendMsg1(C.TOPIC.RECORD, C.ACTIONS.SUBSCRIBE, this._name)
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/** @type {string} */
|