@nxtedition/deepstream.io-client-js 31.0.4 → 31.0.6
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
|
@@ -236,7 +236,7 @@ Connection.prototype._onMessage = function (data) {
|
|
|
236
236
|
Connection.prototype._recvMessages = function (deadline) {
|
|
237
237
|
for (
|
|
238
238
|
let n = 0;
|
|
239
|
-
deadline ? deadline.didTimeout || deadline.timeRemaining() : n < this._batchSize;
|
|
239
|
+
deadline ? deadline.didTimeout || deadline.timeRemaining() > 0 : n < this._batchSize;
|
|
240
240
|
++n
|
|
241
241
|
) {
|
|
242
242
|
const message = this._recvQueue.shift()
|
|
@@ -4,7 +4,6 @@ import UnicastListener from '../utils/unicast-listener.js'
|
|
|
4
4
|
import * as C from '../constants/constants.js'
|
|
5
5
|
import * as rxjs from 'rxjs'
|
|
6
6
|
import invariant from 'invariant'
|
|
7
|
-
import EventEmitter from 'component-emitter2'
|
|
8
7
|
import jsonPath from '@nxtedition/json-path'
|
|
9
8
|
import * as utils from '../utils/utils.js'
|
|
10
9
|
import xuid from 'xuid'
|
|
@@ -121,8 +120,7 @@ class RecordHandler {
|
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
this._syncQueue = []
|
|
124
|
-
this.
|
|
125
|
-
this._readyEmitter = new EventEmitter()
|
|
123
|
+
this._syncMap = {}
|
|
126
124
|
|
|
127
125
|
this.set = this.set.bind(this)
|
|
128
126
|
this.get = this.get.bind(this)
|
|
@@ -649,7 +647,23 @@ class RecordHandler {
|
|
|
649
647
|
}
|
|
650
648
|
|
|
651
649
|
if (message.action === C.ACTIONS.SYNC) {
|
|
652
|
-
|
|
650
|
+
const [token] = message.data
|
|
651
|
+
if (!token) {
|
|
652
|
+
return true
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const sync = this._syncMap[token]
|
|
656
|
+
delete this._syncMap[token]
|
|
657
|
+
|
|
658
|
+
if (!sync) {
|
|
659
|
+
return true
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
const { queue } = sync
|
|
663
|
+
for (let n = 0; n < queue.length; n += 2) {
|
|
664
|
+
queue[n](queue[n + 1])
|
|
665
|
+
}
|
|
666
|
+
|
|
653
667
|
return true
|
|
654
668
|
}
|
|
655
669
|
|
|
@@ -682,9 +696,17 @@ class RecordHandler {
|
|
|
682
696
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.PUT, update)
|
|
683
697
|
}
|
|
684
698
|
|
|
685
|
-
|
|
686
|
-
|
|
699
|
+
const syncMap = {}
|
|
700
|
+
for (const sync of Object.values(this._syncMap)) {
|
|
701
|
+
const token = xuid()
|
|
702
|
+
syncMap[token] = sync
|
|
703
|
+
this._connection.sendMsg(
|
|
704
|
+
C.TOPIC.RECORD,
|
|
705
|
+
C.ACTIONS.SYNC,
|
|
706
|
+
sync.type ? [token, sync.type] : [token],
|
|
707
|
+
)
|
|
687
708
|
}
|
|
709
|
+
this._syncMap = syncMap
|
|
688
710
|
} else {
|
|
689
711
|
this._connected = 0
|
|
690
712
|
}
|
|
@@ -710,11 +732,8 @@ class RecordHandler {
|
|
|
710
732
|
// sync requests from different sockets.
|
|
711
733
|
const token = xuid()
|
|
712
734
|
const queue = this._syncQueue.splice(0)
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
queue[n](queue[n + 1])
|
|
716
|
-
}
|
|
717
|
-
})
|
|
735
|
+
|
|
736
|
+
this._syncMap[token] = { queue, type }
|
|
718
737
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SYNC, type ? [token, type] : [token])
|
|
719
738
|
}, 1)
|
|
720
739
|
}
|