@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "24.4.6",
3
+ "version": "24.4.7",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -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
- this._endpoint = NodeWebSocket
105
- ? new NodeWebSocket(this._url, {
106
- generateMask() {},
107
- })
108
- : new BrowserWebSocket(this._url)
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 = BrowserWebSocket
115
- ? ({ data }) => this._onMessage(typeof data === 'string' ? data : Buffer.from(data).toString())
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) {