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

32 lines
726 B
Go

// Package session builds the session/ file tree for the 9P namespace.
// The tree IS the session collection — sessions are mounted children.
// No manager, no store. Package functions for lifecycle.
package session
import (
"olliesrv/fs"
)
// Get returns the Session mounted at id, or nil.
func Get(root *fs.Tree, id string) *Session {
child := root.Child(id)
if child == nil {
return nil
}
if sess, ok := child.Data.(*Session); ok {
return sess
}
return nil
}
// All returns all mounted sessions.
func All(root *fs.Tree) []*Session {
var sessions []*Session
for _, child := range root.Children() {
if sess, ok := child.Data.(*Session); ok {
sessions = append(sessions, sess)
}
}
return sessions
}