This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-9p/session/session.go

26 lines
644 B
Go

// Package session builds the session/ file tree for the 9P namespace.
// The tree IS the session collection — rootState holds the sessions map.
// Package functions for lifecycle, lookup, and enumeration.
package session
import (
"olliesrv/fs"
)
// Get returns the Session for id, or nil.
func Get(root *fs.Tree, id string) *Session {
return Lookup(root, id)
}
// All returns all active sessions.
func All(root *fs.Tree) []*Session {
rs := state(root)
rs.mu.RLock()
defer rs.mu.RUnlock()
sessions := make([]*Session, 0, len(rs.sessions))
for _, sess := range rs.sessions {
sessions = append(sessions, sess)
}
return sessions
}