-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Description
This issue is originated from nwjs/nw.js#5034. When using Socket.io in latest NW.js, binary data cannot be handles properly.
The root cause is that engine.io-parser doesn't handle ArrayBuffer properly. See lib/index.js:L148-L157.
if (binaryType === 'arraybuffer') { // <-- [1]
var type = data[0]; // <-- [2]
var intArray = new Uint8Array(data.length - 1);
for (var i = 1; i < data.length; i++) {
intArray[i - 1] = data[i];
}
return { type: packetslist[type], data: intArray.buffer };
}
var type = data[0]; // <-- [3]
return { type: packetslist[type], data: data.slice(1) };- In Node.js or NW.js,
binaryTypeis alwaysnull. I assume it's a bug as well. ArrayBuffercannot be directly read using array styled syntaxdata[0]. One should construct a TypedArray form the buffer, such asUint8Array, and read the data inside.- I guess here it assumes
datacould only be a NodeBuffer. However, in NW.jsdatacan be of typeArrayBufferfrom browser builtinWebSocket.
Metadata
Metadata
Assignees
Labels
No labels