Encodes and decodes FireMQ protocol frames.
On TCP and TLS a frame is:
len : u32 | op : u8 | hlen : u32 | header (MessagePack map) | payloadlen counts every byte after itself. The header is a MessagePack map with string keys
and the payload is the raw message body. All integers are big-endian.
The connection reads frames with the socket option packet: 4, so the runtime strips
the length prefix and decode_body/1 sees op | hlen | header | payload. decode/2
handles a byte stream that still carries the prefix.
Summary
Functions
Splits one frame off the front of a byte stream that carries length prefixes.
Decodes a frame without its length prefix.
Encodes a frame with its length prefix, as sent on TCP.
Encodes a frame without its length prefix: the form used on WebSocket and with the
socket option packet: 4.
The 4 bytes a TCP or TLS client sends before its first frame.
Largest frame accepted before welcome, counted from the op byte.
The op code for an op name.
The op name for an op code, or {:unknown, code}.
Every op name, in op-code order.
Types
Functions
@spec decode(binary(), pos_integer()) :: {:ok, t(), binary()} | :more | {:error, String.t()}
Splits one frame off the front of a byte stream that carries length prefixes.
Returns {:ok, frame, rest}, :more when the buffer does not hold a whole frame yet,
or {:error, reason}. max_frame bounds the value of the length prefix.
Decodes a frame without its length prefix.
Encodes a frame with its length prefix, as sent on TCP.
Encodes a frame without its length prefix: the form used on WebSocket and with the
socket option packet: 4.
The 4 bytes a TCP or TLS client sends before its first frame.
Largest frame accepted before welcome, counted from the op byte.
The op code for an op name.
The op name for an op code, or {:unknown, code}.
Every op name, in op-code order.