session

package
v0.0.0-...-f21ad71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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 NewRegistry(defaultWritable bool) *Registry

func (*Registry) Apply

func (r *Registry) Apply(op, name string) (string, error)

Apply executes a guest-management command and returns a human-readable result. Ops: list, allow NAME, deny NAME, kick NAME.

func (*Registry) Broadcast

func (r *Registry) Broadcast(msg protocol.Message)

Broadcast sends msg to every guest, dropping guests whose sockets fail.

func (*Registry) BroadcastExcept

func (r *Registry) BroadcastExcept(skip *Guest, msg protocol.Message)

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) Count

func (r *Registry) Count() int

func (*Registry) HandleInput

func (r *Registry) HandleInput(g *Guest, data []byte, write func(who string, data []byte))

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.

func (*Registry) Join

func (r *Registry) Join(c *wsconn.Conn, requested string) *Guest

Join adds a guest under a sanitized, unique version of its requested name and returns it.

func (*Registry) Leave

func (r *Registry) Leave(g *Guest)

Leave removes a guest (idempotent).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL