module
Amber::WebSockets::Presence
Overview
Module-level presence tracking for WebSocket channels.
This module stores presence data outside the Channel class hierarchy
to avoid Crystal's class variable inheritance behavior where each subclass
gets its own copy of @@ variables. By using a module with extend self,
all channel classes share the same presence store.
Presence data tracks which client sockets are present in each channel topic, along with metadata such as when they joined. This enables features like user lists, online indicators, and presence_diff events.
Extended Modules
Defined in:
amber/websockets/presence.crInstance Method Summary
-
#count(topic_path : String) : Int32
Returns the number of sockets present in the given topic.
-
#has_socket?(topic_path : String, socket_id : String) : Bool
Returns whether a socket is present in the given topic.
-
#list(topic_path : String) : Hash(String, Hash(String, String))
Returns all presence entries for the given topic.
-
#reset
Clears all presence data.
-
#track(topic_path : String, socket_id : String, metadata : Hash(String, String))
Tracks a client socket's presence in the given topic.
-
#untrack(topic_path : String, socket_id : String) : Hash(String, String)
Removes a client socket's presence from the given topic.
Instance Method Detail
Returns the number of sockets present in the given topic.
Returns whether a socket is present in the given topic.
Returns all presence entries for the given topic.
Tracks a client socket's presence in the given topic.