coast-team / netflux

JavaScript client and server side transport API based on WebRTC & WebSocket
https://coast-team.github.io/netflux
GNU Affero General Public License v3.0
213 stars 14 forks source link

Use Protocol Buffer #40

Closed kalitine closed 7 years ago

kalitine commented 7 years ago

Current Behavior Netflux sends messages only as ArrayBuffer. DataView API is used to construct the ArrayBuffer with help of Encoding and JSON APIs. All services' messages are sent as an encoded string and only the message header (3 fields: message type, sender peer id and receiver peer id) are binaries.

Expected Behavior Serialize/deserialize messages with Protocol Buffer. Use proto files for almost all internal messages, instead of string.

What is the motivation / use case for changing the behavior? Improve code maintainability. Decrease the size of messages circulating over the network, thus improve performance.

Tips Protocol Buffer is a specification created by Google. Two its major implementations for Javascript exist as for now:

kalitine commented 7 years ago

Done with protobujs. Internal and communication with Signaling server are via protobuf protocol.