-
Notifications
You must be signed in to change notification settings - Fork 91
Closed
Labels
Description
Currently the SocketCluster client uses a format of:
{"event":"someType","data":{"foo":"bar"},"cid":3}
The format has considerable overhead on the messaging structure and I was wondering how we could go about implementing a buffered-approach such as MessagePack. This could save us big on bandwidth as we're developing an application with a high rate of message throughput.
Right now I'm trying something like:
/**
* Send a Message to Remote over WebSocket.
* Note: This method is part of an abstracted Transport layer used by both Client and Server
*/
send(messageType, message, callback = null) {
// this.socket = SocketCluster socket
if (this.socket.getState() !== 'open') {
return;
}
const encoded = msgpack.encode({event: messageType, data: message}); // returns Buffer
// Get the SocketCluster Transport and send Binary frame
if (this.socket.transport) { // SCClient Socket
this.socket.transport.socket.send(encoded);
} else { // SCServer Socket
this.socket.socket.send(encoded);
}
// The original SocketCluster way which reproduces a "heavy" json string-payload
this.socket.emit(messageType, message);
}
What do you think of supporting raw binary frames directly? And if there's no interest in official support, could you share your thoughts on this? Thanks!