-
Notifications
You must be signed in to change notification settings - Fork 107
Closed
Description
As described here, currently:
socket.send('hello', new Buffer('1234'));
// results in the following packet
var packet = {
type: 5,
data: ['hello', <buffer>],
nsp: '/',
// id: <id> (if used with an acknowledgement)
};
// that gets encoded as two packets by socket.io-parser
[
encodeAsString(packetWithoutBuffer),
<buffer>
]
The thing is, those two packets are sent as two different frames (here), which isn't really efficient (even if a websocket emit does not need a new TCP handshake).
One possible solution would be to concatenate those two packets in one buffer:
var stringPacket = encodeAsString(packetWithoutBuffer);
<stringPacket length><stringPacket as buffer><buffer>
Yet that would be a breaking change, and a special case when handling binary data.
Related:
- execution time for encodeAsBinary #60: execution time for encodeAsBinary
- Getting three frames instead of two between client/server socket.io#2444: Getting three frames instead of two between client/server
- 358 bytes payload takes almost double mobile traffic socket.io#2646: 358 bytes payload takes almost double mobile traffic
Metadata
Metadata
Assignees
Labels
No labels