Raxol. Demo. SessionManager
(Raxol v2.6.0)
View Source
GenServer managing demo terminal sessions. Enforces session limits and handles automatic cleanup.
Summary
Functions
Returns a specification to start this module under a supervisor.
Creates a new session for the given IP address. Returns {:ok, session_id} or {:error, reason}.
Registers a session with a pre-generated session_id. Used when the LiveView creates the session_id before channel join. Returns {:ok, session_id} or {:error, reason}.
Removes a session.
Returns current session count.
Returns session count for an IP.
Starts the session manager.
Refreshes session timeout (called on activity).
Checks if a session exists and belongs to the given IP. Returns {:ok, session_id} or {:error, reason}.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec create_session(ip_address()) :: {:ok, session_id()} | {:error, atom()}
Creates a new session for the given IP address. Returns {:ok, session_id} or {:error, reason}.
@spec register_session(session_id(), ip_address()) :: {:ok, session_id()} | {:error, atom()}
Registers a session with a pre-generated session_id. Used when the LiveView creates the session_id before channel join. Returns {:ok, session_id} or {:error, reason}.
@spec remove_session(session_id()) :: :ok
Removes a session.
@spec session_count() :: non_neg_integer()
Returns current session count.
@spec sessions_for_ip(ip_address()) :: non_neg_integer()
Returns session count for an IP.
Starts the session manager.
@spec touch_session(session_id()) :: :ok
Refreshes session timeout (called on activity).
@spec validate_session(session_id(), ip_address()) :: {:ok, session_id()} | {:error, atom()}
Checks if a session exists and belongs to the given IP. Returns {:ok, session_id} or {:error, reason}.