Documentation
¶
Index ¶
Constants ¶
const ( MsgConfig = "config" MsgClipCreate = "clip:created" MsgClipExpire = "clip:expired" MsgClipList = "clip:list" MsgPing = "ping" )
Message type constants.
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 managed by the Hub.
type ClipListProvider ¶
type ClipListProvider func() interface{}
ClipListProvider is a function that returns all current clips.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub manages all active WebSocket clients and broadcasts messages to them.
func NewHub ¶
NewHub creates a Hub with the given server limits, read timeout, and send buffer size.
func (*Hub) Broadcast ¶
Broadcast sends a message to all registered clients using non-blocking sends. Slow clients that can't keep up are skipped (their channel is not blocked).
func (*Hub) HandleWS ¶
HandleWS is the Gin handler that upgrades HTTP to WebSocket. It sends a "config" message as the first message containing ServerLimits, sets the read deadline, and starts the client read/write pumps.
func (*Hub) SetClipListProvider ¶
func (h *Hub) SetClipListProvider(fn ClipListProvider)
SetClipListProvider sets the function used to retrieve the current clip list.
func (*Hub) Unregister ¶
Unregister removes a client from the hub and closes its send channel.