walter-ws 1.2.0 → 1.2.1
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/client.js +7 -1
- package/src/connection.js +9 -1
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -66,8 +66,10 @@ class WalterClient extends EventEmitter {
|
|
|
66
66
|
this.options = {
|
|
67
67
|
headers: options.headers || null,
|
|
68
68
|
protocols: options.protocols || null,
|
|
69
|
-
maxPayload: options.maxPayload ?? 1024 * 1024,
|
|
69
|
+
maxPayload: options.maxPayload ?? 16 * 1024 * 1024,
|
|
70
70
|
handshakeTimeout: options.handshakeTimeout ?? 10000,
|
|
71
|
+
skipUTF8Validation: options.skipUTF8Validation ?? false,
|
|
72
|
+
rawBuffer: options.rawBuffer ?? false,
|
|
71
73
|
autoReconnect: options.autoReconnect ?? false,
|
|
72
74
|
reconnectInterval: options.reconnectInterval ?? 1000,
|
|
73
75
|
maxReconnectInterval: options.maxReconnectInterval ?? 30000,
|
|
@@ -242,7 +244,11 @@ class WalterClient extends EventEmitter {
|
|
|
242
244
|
this._connection = new WalterConnection(socket, {
|
|
243
245
|
isServer: false,
|
|
244
246
|
maxPayload: this.options.maxPayload,
|
|
247
|
+
skipUTF8Validation: this.options.skipUTF8Validation,
|
|
248
|
+
rawBuffer: this.options.rawBuffer,
|
|
245
249
|
});
|
|
250
|
+
this._socket = socket;
|
|
251
|
+
this.socket = socket;
|
|
246
252
|
|
|
247
253
|
this.readyState = READY_STATES.OPEN;
|
|
248
254
|
this._reconnectAttempts = 0;
|
package/src/connection.js
CHANGED
|
@@ -65,6 +65,8 @@ class WalterConnection extends EventEmitter {
|
|
|
65
65
|
this.socket = socket;
|
|
66
66
|
this.isServer = options.isServer ?? true;
|
|
67
67
|
this.maxPayload = options.maxPayload ?? 1024 * 1024;
|
|
68
|
+
this.skipUTF8Validation = options.skipUTF8Validation ?? false;
|
|
69
|
+
this.rawBuffer = options.rawBuffer ?? false;
|
|
68
70
|
this.request = options.request || null;
|
|
69
71
|
this.readyState = READY_STATES.OPEN;
|
|
70
72
|
this.isAlive = true;
|
|
@@ -336,7 +338,13 @@ class WalterConnection extends EventEmitter {
|
|
|
336
338
|
*/
|
|
337
339
|
_deliverDataMessage(opcode, payload) {
|
|
338
340
|
if (opcode === OPCODES.TEXT) {
|
|
339
|
-
|
|
341
|
+
if (this.rawBuffer) {
|
|
342
|
+
this.emit('message', payload, false);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const text = this.skipUTF8Validation
|
|
346
|
+
? payload.toString('utf8')
|
|
347
|
+
: decodeUTF8Strict(payload);
|
|
340
348
|
this.emit('message', text, false);
|
|
341
349
|
} else if (opcode === OPCODES.BINARY) {
|
|
342
350
|
this.emit('message', payload, true);
|