Codebase
Session Manager
sessions/session.go: sessions package
Structs
Session represents a single connected user
type Session struct {
Username string
SessionToken string -- hexidecimal string generated by crypto package
Conn *websocket.Conn -- Websocket connection
ConnectedAt time.Time -- time when the user connected
}
Groups up the sessions
// SessionManager manages all active sessions
type SessionManager struct {
Sessions map[string]*Session // key: session token
Mu sync.RWMutex
}
Methods
Session Manager
Add(session *Session)