32 lines
726 B
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
|
|
}
|