Documentation
¶
Overview ¶
Package session tracks the guests of one cotty session: their names, per-guest write permission, and presence. It backs both a locally hosted session and a session living on a relay.
Index ¶
- type Guest
- type Registry
- func (r *Registry) Apply(op, name string) (string, error)
- func (r *Registry) Broadcast(msg protocol.Message)
- func (r *Registry) BroadcastExcept(skip *Guest, msg protocol.Message)
- func (r *Registry) CloseAll()
- func (r *Registry) Count() int
- func (r *Registry) HandleInput(g *Guest, data []byte, write func(who string, data []byte))
- func (r *Registry) Join(c *wsconn.Conn, requested string) *Guest
- func (r *Registry) Leave(g *Guest)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Guest ¶
type Guest struct {
Name string
Writable bool
JoinedAt time.Time
// contains filtered or unexported fields
}
Guest is one connected participant.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the guest list of one session. All methods are safe for concurrent use.
func NewRegistry ¶
func (*Registry) Apply ¶
Apply executes a guest-management command and returns a human-readable result. Ops: list, allow NAME, deny NAME, kick NAME.
func (*Registry) Broadcast ¶
Broadcast sends msg to every guest, dropping guests whose sockets fail.
func (*Registry) BroadcastExcept ¶
BroadcastExcept sends msg to every guest but skip (used for join/leave notices, which the affected guest doesn't need to hear about itself).
func (*Registry) CloseAll ¶
func (r *Registry) CloseAll()
CloseAll disconnects every guest and empties the registry.
func (*Registry) HandleInput ¶
HandleInput applies one guest's keystrokes if that guest may write, warning it once otherwise. Applied input is attributed to the guest by name, and other participants get a throttled "is typing" announcement.