-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Would have been nice with a binary protocol instead of base64
base64 adds a 1/3 extra bandwidth, and it is wasteful to have to decode and encode stuff and include a base64 encoder/deocder to do so.
const ws = new WebSocket(...)
ws.binaryType = "arraybuffer";so JSON don't fit in well when you want to send binary data. and retrieving json with binary data don't make the communication any better
- have the first byte or something be the
data.codeor something - have the first 2-x bytes indicate how long your (possible json) message is and the rest of the binary is the actual "data.data" (aka binary payload)
and with a binary protocol then i don't mean some BSON, protobuf or any other serialization that you would need a library for IMO,
should be dependent free and easy to parse with vanilla javascript (DataView comes to mind if you need something more fancy)
TextEncoder & TextDecoder, is easy to use if you have to convert to/from string & buffer
Metadata
Metadata
Assignees
Labels
No labels