@nxtedition/deepstream.io-client-js 24.4.6 → 24.4.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 +1 -1
- package/src/message/connection.js +12 -8
package/package.json
CHANGED
|
@@ -31,6 +31,7 @@ const Connection = function (client, url, options) {
|
|
|
31
31
|
this._reconnectTimeout = null
|
|
32
32
|
this._reconnectionAttempt = 0
|
|
33
33
|
this._endpoint = null
|
|
34
|
+
this._decoder = new TextDecoder()
|
|
34
35
|
|
|
35
36
|
this._processingRecv = false
|
|
36
37
|
this._recvMessages = this._recvMessages.bind(this)
|
|
@@ -101,19 +102,22 @@ Connection.prototype.close = function () {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
Connection.prototype._createEndpoint = function () {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
if (utils.isNode) {
|
|
106
|
+
this._endpoint = new NodeWebSocket(this._url, {
|
|
107
|
+
generateMask() {},
|
|
108
|
+
})
|
|
109
|
+
this._endpoint.binaryType = 'nodebuffer'
|
|
110
|
+
} else {
|
|
111
|
+
this._endpoint = new BrowserWebSocket(this._url)
|
|
112
|
+
this._endpoint.binaryType = 'arraybuffer'
|
|
113
|
+
}
|
|
109
114
|
this._corked = false
|
|
110
115
|
|
|
111
116
|
this._endpoint.onopen = this._onOpen.bind(this)
|
|
112
117
|
this._endpoint.onerror = this._onError.bind(this)
|
|
113
118
|
this._endpoint.onclose = this._onClose.bind(this)
|
|
114
|
-
this._endpoint.onmessage =
|
|
115
|
-
|
|
116
|
-
: ({ data }) => this._onMessage(typeof data === 'string' ? data : data.toString())
|
|
119
|
+
this._endpoint.onmessage = ({ data }) =>
|
|
120
|
+
this._onMessage(typeof data === 'string' ? data : this._decoder.decode(data))
|
|
117
121
|
}
|
|
118
122
|
|
|
119
123
|
Connection.prototype.send = function (message) {
|