Skip to content

Commit af96d1b

Browse files
Merge pull request #7 from overleaf/ae-concat-buffer
Only convert the current message to a string once the last fragment has been received
2 parents ddbee7b + 8f08d04 commit af96d1b

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

History.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
0.9.19-overleaf-6 / 2022-08-18
2+
==============================
3+
4+
* Overleaf: only convert the current message to a string once the last fragment has been received
5+
16
0.9.19-overleaf-5 / 2021-05-19
27
==============================
38

lib/transports/websocket/hybi-16.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ function Parser (opts) {
281281
this.expectOffset = 0;
282282
this.expectBuffer = null;
283283
this.expectHandler = null;
284-
this.currentMessage = '';
284+
this.currentMessage = [];
285285
this._maxBuffer = (opts && opts.maxBuffer) || 10E7;
286286
this._dataLength = 0;
287287

@@ -290,10 +290,10 @@ function Parser (opts) {
290290
// text
291291
'1': function(data) {
292292
var finish = function(mask, data) {
293-
self.currentMessage += self.unmask(mask, data);
293+
self.currentMessage.push(self.unmask(mask, data, true));
294294
if (self.state.lastFragment) {
295-
self.emit('data', self.currentMessage);
296-
self.currentMessage = '';
295+
self.emit('data', self.concatBuffers(self.currentMessage).toString('utf8'));
296+
self.currentMessage = [];
297297
}
298298
self.endPacket();
299299
}
@@ -338,11 +338,10 @@ function Parser (opts) {
338338
// binary
339339
'2': function(data) {
340340
var finish = function(mask, data) {
341-
if (typeof self.currentMessage == 'string') self.currentMessage = []; // build a buffer list
342341
self.currentMessage.push(self.unmask(mask, data, true));
343342
if (self.state.lastFragment) {
344343
self.emit('binary', self.concatBuffers(self.currentMessage));
345-
self.currentMessage = '';
344+
self.currentMessage = [];
346345
}
347346
self.endPacket();
348347
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socket.io"
3-
, "version": "0.9.19-overleaf-5"
3+
, "version": "0.9.19-overleaf-6"
44
, "description": "Real-time apps made cross-browser & easy with a WebSocket-like API"
55
, "homepage": "http://socket.io"
66
, "keywords": ["websocket", "socket", "realtime", "socket.io", "comet", "ajax"]

0 commit comments

Comments
 (0)