Documentation
¶
Overview ¶
Package ws serves live values over WebSocket (spec 9.3): subscriptions per client, a per-client diff against what was sent, pushes coalesced into one frame per tick.
Index ¶
Constants ¶
const ( MaxClients = 256 MaxKeys = 256 // per frame, in both directions MaxMessage = 1 << 20 )
Limits (spec 9.3).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus interface {
Subscribe(size int, policy eventbus.Overflow) *eventbus.Subscription
Unsubscribe(s *eventbus.Subscription)
}
Bus is the part of the event bus the hub subscribes to.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler upgrades GET /ws and runs one connection on the current hub. The upgrader keeps the library's same-origin check (Origin host == Host).
func NewHandler ¶
NewHandler builds the handler for the hub published in slot.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub is the restartable component that owns all clients. The HTTP handler reaches the current instance through a util.Slot, because a restart replaces it.
func NewHub ¶
func NewHub(s *site.Site, cache Cache, bus Bus, clock util.Clock, slot *util.Slot[*Hub], ) (*Hub, error)
NewHub builds a hub for the live keys of site s and publishes it in slot on Start.