Documentation
¶
Overview ¶
CRC: crc-SessionManager.md Spec: interfaces.md, protocol.md
Package session implements session management for the UI server. CRC: crc-Session.md, crc-SessionManager.md Spec: main.md (UI Server Architecture - Frontend Layer), interfaces.md
Index ¶
- func GenerateSessionID() string
- type Manager
- func (m *Manager) CleanupInactiveSessions() int
- func (m *Manager) Count() int
- func (m *Manager) CreateSession() (*Session, string, error)
- func (m *Manager) DestroySession(id string) error
- func (m *Manager) Get(id string) *Session
- func (m *Manager) GetAllSessions() []*Session
- func (m *Manager) GetInternalID(vendedID string) string
- func (m *Manager) GetSession(id string) (*Session, bool)
- func (m *Manager) GetVendedID(internalID string) string
- func (m *Manager) RegisterURLPath(sessionID, path string, variableID int64) error
- func (m *Manager) ResolveURLPath(sessionID, path string) (int64, bool)
- func (m *Manager) SessionExists(id string) bool
- func (m *Manager) SetOnSessionCreated(callback SessionCreatedCallback)
- func (m *Manager) SetOnSessionDestroyed(callback SessionDestroyedCallback)
- type Session
- func (s *Session) AddConnection(connectionID string)
- func (s *Session) GetAppVariableID() int64
- func (s *Session) GetBackend() backend.Backend
- func (s *Session) GetConnectionCount() int
- func (s *Session) GetConnections() []string
- func (s *Session) GetCreatedAt() time.Time
- func (s *Session) GetID() string
- func (s *Session) GetLastActivity() time.Time
- func (s *Session) IsActive() bool
- func (s *Session) RemoveConnection(connectionID string) bool
- func (s *Session) SetAppVariableID(id int64)
- func (s *Session) SetBackend(b backend.Backend)
- func (s *Session) Touch()
- type SessionCreatedCallback
- type SessionDestroyedCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSessionID ¶
func GenerateSessionID() string
GenerateSessionID creates a unique session identifier.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages all sessions.
func NewManager ¶
NewManager creates a new session manager.
func (*Manager) CleanupInactiveSessions ¶
CleanupInactiveSessions removes sessions with no activity past the timeout.
func (*Manager) CreateSession ¶
CreateSession generates a new session ID and initializes the session. Returns the session and its vended ID (compact integer string for backend communication). Note: Variable 1 (app variable) is NOT created here. It's created by: - Lua main.lua calling session:createAppVariable() (Lua-only mode) - External backend via protocol (backend-only mode)
func (*Manager) DestroySession ¶
DestroySession cleans up a session and all its resources.
func (*Manager) GetAllSessions ¶
GetAllSessions returns all sessions.
func (*Manager) GetInternalID ¶
GetInternalID returns the internal session ID for a vended ID. Returns empty string if session not found.
func (*Manager) GetSession ¶
GetSession retrieves a session by ID.
func (*Manager) GetVendedID ¶
GetVendedID returns the vended ID for an internal session ID. Returns empty string if session not found.
func (*Manager) RegisterURLPath ¶
RegisterURLPath associates a URL path with a presenter variable for a session.
func (*Manager) ResolveURLPath ¶
ResolveURLPath finds the presenter variable for a URL path in a session.
func (*Manager) SessionExists ¶
SessionExists checks if a session ID is valid.
func (*Manager) SetOnSessionCreated ¶
func (m *Manager) SetOnSessionCreated(callback SessionCreatedCallback)
SetOnSessionCreated sets a callback called when a session is created.
func (*Manager) SetOnSessionDestroyed ¶
func (m *Manager) SetOnSessionDestroyed(callback SessionDestroyedCallback)
SetOnSessionDestroyed sets a callback called when a session is destroyed.
type Session ¶
type Session struct {
ID string
AppVariableID int64 // Variable 1 - root app variable
// contains filtered or unexported fields
}
Session represents a single user session. Session is part of the frontend layer - it routes messages to backend. CRC: crc-Session.md
func NewSession ¶
NewSession creates a new session with the given ID.
func (*Session) AddConnection ¶
AddConnection registers a new connection to this session.
func (*Session) GetAppVariableID ¶
GetAppVariableID returns the root variable ID.
func (*Session) GetBackend ¶
GetBackend returns the backend instance for this session.
func (*Session) GetConnectionCount ¶
GetConnectionCount returns the number of active connections.
func (*Session) GetConnections ¶
GetConnections returns a copy of the connection IDs.
func (*Session) GetCreatedAt ¶
GetCreatedAt returns the session creation time.
func (*Session) GetLastActivity ¶
GetLastActivity returns the last activity time.
func (*Session) RemoveConnection ¶
RemoveConnection unregisters a connection from this session. Calls backend.UnwatchAll to clean up watches for this connection. Returns true if this was the last frontend connection. CRC: crc-Session.md
func (*Session) SetAppVariableID ¶
SetAppVariableID sets the root variable ID.
func (*Session) SetBackend ¶
SetBackend sets the backend instance for this session.
type SessionCreatedCallback ¶
SessionCreatedCallback is called when a new session is created. Receives the vended session ID (compact integer string) and the session object.
type SessionDestroyedCallback ¶
SessionDestroyedCallback is called when a session is destroyed. Receives the vended session ID (compact integer string) and the session object.