Object.NetworkProtocol (object v0.1.2)
Binary protocol for efficient Object communication over network.
Implements a high-performance binary protocol with support for:
- Message framing and fragmentation
- Request/response and streaming patterns
- Compression and encryption
- Version negotiation
- Heartbeat and health checking
Protocol Format
| 1 byte | 1 byte | 2 bytes | 4 bytes | Variable |
| Version | Type | Flags | Length | Payload |
Message Types
- 0x01: HELLO - Initial handshake
- 0x02: HELLO_ACK - Handshake acknowledgment
- 0x10: REQUEST - Request message
- 0x11: RESPONSE - Response message
- 0x12: STREAM_START - Start streaming
- 0x13: STREAM_DATA - Stream chunk
- 0x14: STREAM_END - End streaming
- 0x20: CAST - One-way message
- 0x30: HEARTBEAT - Keepalive
- 0x31: HEARTBEAT_ACK - Keepalive response
- 0xFF: ERROR - Error message
Summary
Functions
Creates a cast (one-way) message.
Creates a heartbeat message.
Creates a heartbeat acknowledgment.
Creates a request message.
Creates a response message.
Decodes a binary message into structured format.
Encodes a message into binary protocol format.
Fragments a large message into smaller chunks.
Reassembles fragmented messages.
Types
@type message() :: %{ version: non_neg_integer(), type: message_type(), flags: non_neg_integer(), id: binary(), correlation_id: binary() | nil, payload: term(), metadata: map() }
@type message_type() ::
:hello
| :hello_ack
| :request
| :response
| :stream_start
| :stream_data
| :stream_end
| :cast
| :heartbeat
| :heartbeat_ack
| :error
Functions
Creates a cast (one-way) message.
@spec create_heartbeat() :: message()
Creates a heartbeat message.
Creates a heartbeat acknowledgment.
Creates a request message.
Creates a response message.
Decodes a binary message into structured format.
@spec encode(message(), encode_opts()) :: {:ok, binary()} | {:error, term()}
Encodes a message into binary protocol format.
@spec fragment_message(binary(), pos_integer()) :: [binary()]
Fragments a large message into smaller chunks.
Reassembles fragmented messages.