Skip to content

Binary protocol#426

Merged
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
gloskull:binary-protocol
May 27, 2026
Merged

Binary protocol#426
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
gloskull:binary-protocol

Conversation

@gloskull
Copy link
Copy Markdown
Contributor

@gloskull gloskull commented May 27, 2026

Closes #406


Motivation

  • Reduce WebSocket payload size and bandwidth by replacing JSON envelopes with a compact protobuf-style binary envelope for high-frequency real-time events.
  • Keep backward compatibility so unknown events and existing JSON payloads continue to work via a JSON fallback.

Description

  • Added src/services/socket/binaryProtocol.ts which implements manual varint/fixed64/length-delimited encoding/decoding, event schemas for notification_created, course_updated, and message_received, and estimatePayloadReduction to compare JSON vs binary sizes.
  • Updated src/services/socket/index.ts to encodeBinaryMessage on outbound emit and to decodeBinaryMessage for inbound ArrayBuffer/Uint8Array frames while preserving existing socket lifecycle and reconnection behavior.
  • Added tests at src/__tests__/services/binaryProtocol.test.ts that validate known-event round-trip, unknown-event JSON fallback, and payload reduction metrics.
  • Documented the protocol shape and usage in README.md under the new "WebSocket Binary Protocol" section.

Testing

  • Added unit tests in src/__tests__/services/binaryProtocol.test.ts which exercise encodeBinaryMessage, decodeBinaryMessage, and estimatePayloadReduction.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@gloskull Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER RUKAYAT-CODER merged commit 18e8125 into rinafcode:main May 27, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement binary protocol for WebSocket communication - HTTP/2 Server Push

2 participants