41 lines
1.5 KiB
Go
41 lines
1.5 KiB
Go
package menu
|
|
|
|
import "time"
|
|
|
|
// NodeInfo describes an active node for display and management.
|
|
// This is the information the menu layer needs about connected sessions
|
|
// without requiring direct access to the session objects themselves.
|
|
//
|
|
// The original TAG-BBS was single-user, so there was no concept of
|
|
// node management. The closest equivalent was the sysop console's
|
|
// ability to see who was online and boot them. NodeInfo enables the
|
|
// same functionality in our multi-node architecture.
|
|
type NodeInfo struct {
|
|
Node int
|
|
RemoteAddr string
|
|
UserName string // Empty for pre-login connections
|
|
UserID int64 // 0 for guests or pre-login
|
|
ConnectedAt time.Time
|
|
}
|
|
|
|
// NodeManager provides read and control operations over active nodes.
|
|
// It abstracts the server's session management so the menu layer can
|
|
// list, message, and disconnect nodes without coupling to the server
|
|
// implementation.
|
|
//
|
|
// The server.Server struct implements this interface. The menu package
|
|
// consumes it through the Context.
|
|
type NodeManager interface {
|
|
// ActiveNodes returns info about all currently connected sessions.
|
|
ActiveNodes() []NodeInfo
|
|
|
|
// DisconnectNode forcibly disconnects the given node number.
|
|
// Returns an error if the node doesn't exist.
|
|
DisconnectNode(node int) error
|
|
|
|
// SendToNode sends a message string to the given node's terminal.
|
|
// Used for inter-node chat and sysop announcements.
|
|
// Returns an error if the node doesn't exist.
|
|
SendToNode(node int, msg string) error
|
|
}
|