@nxtedition/deepstream.io-client-js 32.0.23 → 32.0.25
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 +11 -3
package/package.json
CHANGED
|
@@ -28,7 +28,6 @@ export default function Connection(client, url, options) {
|
|
|
28
28
|
action: null,
|
|
29
29
|
data: null,
|
|
30
30
|
}
|
|
31
|
-
this._decoder = new globalThis.TextDecoder()
|
|
32
31
|
this._recvQueue = new FixedQueue()
|
|
33
32
|
this._reconnectTimeout = null
|
|
34
33
|
this._reconnectionAttempt = 0
|
|
@@ -96,9 +95,20 @@ Connection.prototype._createEndpoint = function () {
|
|
|
96
95
|
generateMask() {},
|
|
97
96
|
})
|
|
98
97
|
this._endpoint.binaryType = 'nodebuffer'
|
|
98
|
+
this._endpoint.onmessage = ({ data: buf }) => {
|
|
99
|
+
this._onMessage(buf.toString('utf8', buf[0] > 128 ? buf[0] - 128 : 0))
|
|
100
|
+
}
|
|
99
101
|
} else {
|
|
102
|
+
const decoder = new globalThis.TextDecoder()
|
|
100
103
|
this._endpoint = new BrowserWebSocket(this._url)
|
|
101
104
|
this._endpoint.binaryType = 'arraybuffer'
|
|
105
|
+
this._endpoint.onmessage = ({ data }) => {
|
|
106
|
+
let buf = new Uint8Array(data)
|
|
107
|
+
if (buf[0] > 128) {
|
|
108
|
+
buf = buf.subarray(buf[0] - 128)
|
|
109
|
+
}
|
|
110
|
+
this._onMessage(decoder.decode(buf))
|
|
111
|
+
}
|
|
102
112
|
}
|
|
103
113
|
|
|
104
114
|
this._corked = false
|
|
@@ -106,8 +116,6 @@ Connection.prototype._createEndpoint = function () {
|
|
|
106
116
|
this._endpoint.onopen = this._onOpen.bind(this)
|
|
107
117
|
this._endpoint.onerror = this._onError.bind(this)
|
|
108
118
|
this._endpoint.onclose = this._onClose.bind(this)
|
|
109
|
-
this._endpoint.onmessage = ({ data }) =>
|
|
110
|
-
this._onMessage(typeof data === 'string' ? data : this._decoder.decode(data))
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
Connection.prototype.send = function (message) {
|