[Enhancement] Use binary messages for websocket transfer
bt90 opened this issue · 1 comments
@schlagmichdoch I took a look at the current codebase and apparently the websocket transfer uses base64 encoded content to be transferable as a single JSON message. Would it be possible to split this? e.g. send the control message as JSON and then send the data as a binary message?
The reason I ask is because base64 adds 33% overhead for each file.
Originally posted by @bt90 in #228 (comment)
This was the easiest way to implement the websocket fallback as each message must also include the addressee to be able to relay it. Probably there are other optimized methods than sending it encoded as text. I also think all peer to peer communication should be at least transport encrypted as with WebRTC transfers but this too is not implemented yet. (See this comment and the following)
Originally posted by @schlagmichdoch in #228 (comment)
Follow up issue for #228 (comment)
Maybe we could switch from JSON to protobuf? That would keep things together as a single message, while avoiding the overhead of base64.
Something like protobuf would probably be the cleanest, thanks for the suggestion! Alternatively we could bundle up our own protocol by defining something like:
- first 36bytes: uuid
- next 4 bytes chunkid
- everything that follows: data
I think it's also possible to convert json containing ArrayBuffers into raw data and send that.
I would definitely need to do some research first.
I'm a little short on time right now so I this will probably only be implemented in v2.1
as I want to finish everything listed here first (#267)