Documentation
¶
Overview ¶
Package room shares workbooks between the people 012 serve hosts: a room is one workbook, opened by every session that opens the same file (or joins the same named room), and each participant has a seat in it. The server holds the workbook, so there is no merging: every participant acts on it in turn, under the room's lock, and the steps they make are ordered by the workbook's one mutation path (Batch and its undo steps), each attributed to its author, as a stream of operations (sheet.Op) the room hands every participant. A participant is anything with a name that can be told the room changed (Participant): a served session's model. The interface stays that small so an MCP client attached to the server can take part the same way (ROADMAP.md, Agents). See docs/contributing/architecture.md.
Index ¶
- Constants
- type Mark
- type Mode
- type Participant
- type Peer
- type Presence
- type Registry
- type Room
- type Saved
- type Seat
- func (s *Seat) Book() *sheet.Workbook
- func (s *Seat) Color() int
- func (s *Seat) Do(fn func(w *sheet.Workbook))
- func (s *Seat) HandTo(id int) bool
- func (s *Seat) ID() int
- func (s *Seat) Keeper() bool
- func (s *Seat) Key() string
- func (s *Seat) Last() uint64
- func (s *Seat) Leave() (last bool)
- func (s *Seat) Marks(since uint64) []Mark
- func (s *Seat) Mode() Mode
- func (s *Seat) Move(p Presence)
- func (s *Seat) Name() string
- func (s *Seat) Others() int
- func (s *Seat) Peers() []Peer
- func (s *Seat) Post(msg any)
- func (s *Seat) Saved() Saved
- func (s *Seat) SetSaved(v Saved)
- func (s *Seat) Take() []any
- func (s *Seat) Value(key string, make func() any) any
- func (s *Seat) Writer() string
- func (s *Seat) Writing() bool
Constants ¶
const Colors = 6
Colors is how many colors participants are told apart by.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mark ¶
type Mark struct {
Seq uint64
Author int
Name string
Color int
Kind sheet.OpKind
Label string
Sheet *sheet.Sheet
Rect sheet.Rect
At time.Time
}
Mark is an operation's place in the workbook: who changed which cells, for showing whose change a cell holds.
type Participant ¶
type Participant interface {
// Name is who they are to the others: the SSH user of a session.
Name() string
// Notify tells them the room changed: someone else's operations,
// where the others are, who writes, a save, a message posted for
// them. It's called with the room locked, so it must neither block
// nor call back into the room: they look at what changed on their
// next turn (Seat.Do).
Notify()
}
Participant is one who takes part in a room. The room asks only this of it; everything else a participant does, it does through its Seat.
type Peer ¶
Peer is what a participant sees of another: who, in what color, where, and whether they write.
type Presence ¶
type Presence struct {
Sheet *sheet.Sheet
Cursor sheet.Addr
Selection sheet.Rect
Editing bool // typing into the cell at Cursor
}
Presence is where a participant is.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the rooms a server holds, by key: a file's path, or @name for a named room.
func NewRegistry ¶
NewRegistry holds rooms whose participants edit as mode says.
func (*Registry) Join ¶
Join seats p in the room with key, opening it on the workbook book makes when there's none (book is called with no lock held but the registry's, and may be nil when the room is known to be open). It reports whether it opened the room. A room's history is shared: undo takes back each participant's own steps.
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
Room is one shared workbook and the seats of those in it.
type Saved ¶
type Saved struct {
State int // the workbook's StateID then
Outputs int // its OutputsChanged then
Name string // the file's name, as typed, "" for none
Key string // the file's room key, its path: the room is its room too
Stamp any // the file on disk then, the UI's to compare
}
Saved is the room's file as last saved or opened: what every session in it counts unsaved changes from.
type Seat ¶
type Seat struct {
// contains filtered or unexported fields
}
Seat is a participant's place in a room.
func (*Seat) Do ¶
Do runs fn as the participant's turn: with the room locked, the workbook's steps made in the participant's name. When the turn ends, the others are told of what changed.
func (*Seat) HandTo ¶
HandTo hands the writer's role to the participant with id, reporting false when this one doesn't write or there's no such participant. Call it in a turn.
func (*Seat) Keeper ¶
Keeper reports whether the participant keeps what the room runs on its own (linked files followed, notebook cells running): the one who has been there longest. Call it in a turn.
func (*Seat) Leave ¶
Leave gives up the seat, reporting whether it was the last: the room closes then, and its workbook is the participant's alone.
func (*Seat) Marks ¶
Marks are the operations since seq, oldest first, whoever made them. Call it in a turn.
func (*Seat) Move ¶
Move sets where the participant is, for the others to see once the turn ends. Call it in a turn.
func (*Seat) Post ¶
Post leaves msg for the keeper, whoever it is when it takes it: what the room runs reports back this way rather than to the participant that started it, who may have left. It may be called from any goroutine, outside a turn.
func (*Seat) SetSaved ¶
SetSaved records a save, or the file the room was opened from, for every session. Call it in a turn.
func (*Seat) Take ¶
Take is what was posted for the keeper, if this is the keeper. Call it in a turn.
func (*Seat) Value ¶
Value is the room's value for key, made by make the first time: state every participant shares, such as the notebook cells running. Call it in a turn.