Phoenix Channel v1.0.0 JSON wire protocol for Supabase Realtime.
Pure builders + parser. No I/O, no state. The connection module composes these into a transport-bound conversation.
{:topic "realtime:room:lobby"
:event "phx_join"
:payload {...}
:ref "1"
:join_ref "1"} ; only on channel-bound messages
event-kind returns one of:
:phx-reply :phx-close :phx-error
:postgres-changes :broadcast
:presence-state :presence-diff
:system :heartbeat-reply :unknown
Phoenix Channel v1.0.0 JSON wire protocol for Supabase Realtime.
Pure builders + parser. No I/O, no state. The connection module composes
these into a transport-bound conversation.
## Frame shape
{:topic "realtime:room:lobby"
:event "phx_join"
:payload {...}
:ref "1"
:join_ref "1"} ; only on channel-bound messages
## Event kinds
`event-kind` returns one of:
:phx-reply :phx-close :phx-error
:postgres-changes :broadcast
:presence-state :presence-diff
:system :heartbeat-reply :unknown(access-token-frame ref join-ref topic token)Builds an access_token event frame to refresh auth for a joined channel.
Builds an `access_token` event frame to refresh auth for a joined channel.
(broadcast-frame ref join-ref topic event payload)Builds a broadcast frame. Server echoes back to other subscribers
(and to self when broadcast.self is enabled).
Builds a broadcast frame. Server echoes back to other subscribers (and to self when `broadcast.self` is enabled).
(encode frame)JSON-encodes frame to a string.
JSON-encodes `frame` to a string.
(event-kind frame)Returns the kind keyword for a decoded inbound frame. :unknown for
events not recognized — caller should log + ignore.
Returns the kind keyword for a decoded inbound frame. `:unknown` for events not recognized — caller should log + ignore.
(heartbeat-frame ref)Builds a heartbeat frame on the reserved phoenix topic.
Builds a heartbeat frame on the reserved `phoenix` topic.
(join-frame ref topic config bindings access-token)Builds a phx_join frame for topic with the given channel config
and bindings vector. access-token is optional and added to the
payload when present.
Builds a `phx_join` frame for `topic` with the given channel `config` and `bindings` vector. `access-token` is optional and added to the payload when present.
(leave-frame ref join-ref topic)Builds a phx_leave frame.
Builds a `phx_leave` frame.
(next-ref counter)Increments counter and returns the new value as a string.
Increments `counter` and returns the new value as a string.
(parse-frame text)Parses a JSON text frame into a Clojure map with keyword keys.
Payload values are returned as-is (postgres column names stay snake_case).
Parses a JSON text frame into a Clojure map with keyword keys. Payload values are returned as-is (postgres column names stay snake_case).
(presence-track-frame ref join-ref topic state)Builds a presence track frame for the given state map.
Builds a presence track frame for the given `state` map.
(presence-untrack-frame ref join-ref topic)Builds a presence untrack frame.
Builds a presence untrack frame.
(realtime-topic topic)Ensures a topic is prefixed with realtime:. Idempotent.
Ensures a topic is prefixed with `realtime:`. Idempotent.
(ref-counter)Returns an atom suitable for generating monotonic outgoing :ref ids.
Returns an atom suitable for generating monotonic outgoing `:ref` ids.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |