Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a single WebSocket connection.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub manages WebSocket client connections and broadcasts messages. All map mutations happen inside Run, so no mutex is needed on the hot path.
func (*Hub) Broadcast ¶
Broadcast enqueues a message for asynchronous fan-out. It is non-blocking: if the broadcast queue is full the message is dropped rather than stalling the caller (typically a store write path).
func (*Hub) ClientCount ¶
ClientCount returns the number of connected clients.
func (*Hub) Run ¶
Run starts the hub event loop. It blocks until ctx is cancelled. The Run goroutine is the sole owner of the clients map and the only writer to client.send, which means Broadcast callers never block on JSON marshaling.
func (*Hub) Unregister ¶
Unregister removes a client from the hub.
type Message ¶
type Message struct {
Type store.SignalType `json:"type"`
Data any `json:"data"`
}
Message is sent to WebSocket clients.