ProtoChannel. Serializer
(ProtoChannel v0.1.1)
Copy Markdown
A Phoenix.Socket.Serializer that frames every socket frame as a
protobuf Envelope message (defined in priv/proto/wire.proto).
Endpoint wiring
socket "/socket", MyAppWeb.UserSocket,
websocket: [serializer: [{ProtoChannel.Serializer, "~> 2.0.0"}]],
longpoll: falsePayload contract
The serializer is intentionally narrow:
{:binary, bytes}— written verbatim to the envelope'spayloadfield.%{}(empty map) — encoded as zero bytes; tolerated because Phoenix uses empty maps as join acknowledgements.- Anything else raises
ArgumentError.
On decode, payloads are always wrapped as {:binary, bytes}. Empty
join_ref / ref strings round-trip back to nil.
Wire format
The envelope is defined in priv/proto/wire.proto. It carries a kind enum
(PUSH, REPLY, BROADCAST) plus join_ref, ref, topic, event,
status, and payload fields.
This serializer composes with the ProtoChannel macro but does not require
it — any channel that produces {:binary, bytes} payloads works.