Tracks active WebSocket channel and WebRTC peer connections using a Registry
with :duplicate keys.
Each channel process registers itself on join via register/2. Because
Registry links to the registering process, entries are automatically
removed when the process terminates — no manual cleanup needed.
Connection types
:ws_socket— raw WebSocket connections (1 per client):user_channel— authenticated user WebSocket channels:lobby_channel— per-lobby channels (members + spectators):lobbies_channel— global lobbies listing channel:group_channel— per-group channels:groups_channel— global groups listing channel:party_channel— per-party channels:live_view— active LiveView connections (browser tabs):webrtc_peer— active WebRTC DataChannel peers
Summary
Functions
Returns a map with counts for every tracked connection type plus totals.
In a clustered environment, this only counts connections on the local node.
Use cluster_counts/0 for aggregated counts across all nodes.
Returns all connection types and their registered processes.
Returns the child spec to start the underlying Registry. Add this to your supervision tree before the Endpoint.
Returns aggregated connection counts across all connected nodes in the cluster. Falls back to local-only counts if the cluster has a single node.
Returns the count of processes registered under type.
Returns 0 if the registry hasn't been started yet.
Counts this user's live user channels excluding the calling process — used on disconnect to decide whether the user just went fully offline.
Counts this user's live WebSocket connections on this node.
Formats uptime seconds into a human-readable string like "2d 3h 15m".
Returns a list of {pid, metadata} tuples for all processes registered
under the given type.
Registers the calling process under the given connection type.
Optional metadata map is stored alongside the registration.
Registers a user channel under both the :user_channel type (for counts) and
a per-user key, so the "does this user have any other socket?" check on
disconnect is O(sockets-for-this-user) instead of O(all user channels).
Registers a raw WebSocket under both the :ws_socket type (for counts and
the admin runtime page) and a per-user key.
Returns BEAM system statistics useful for the admin dashboard.
Functions
Returns a map with counts for every tracked connection type plus totals.
In a clustered environment, this only counts connections on the local node.
Use cluster_counts/0 for aggregated counts across all nodes.
Returns all connection types and their registered processes.
Returns the child spec to start the underlying Registry. Add this to your supervision tree before the Endpoint.
Returns aggregated connection counts across all connected nodes in the cluster. Falls back to local-only counts if the cluster has a single node.
Returns the count of processes registered under type.
Returns 0 if the registry hasn't been started yet.
Counts this user's live user channels excluding the calling process — used on disconnect to decide whether the user just went fully offline.
Counts this user's live WebSocket connections on this node.
Formats uptime seconds into a human-readable string like "2d 3h 15m".
Returns a list of {pid, metadata} tuples for all processes registered
under the given type.
Registers the calling process under the given connection type.
Optional metadata map is stored alongside the registration.
Returns {:ok, pid} or {:error, term}.
No-op if the registry hasn't been started yet.
Registers a user channel under both the :user_channel type (for counts) and
a per-user key, so the "does this user have any other socket?" check on
disconnect is O(sockets-for-this-user) instead of O(all user channels).
Registers a raw WebSocket under both the :ws_socket type (for counts and
the admin runtime page) and a per-user key.
The per-user key is what the connection limit is counted from: scanning the
:ws_socket duplicate key returns every socket on the node, which made each
new connection O(all sockets) and a connection storm O(n^2).
Returns BEAM system statistics useful for the admin dashboard.