Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a middleman between the websocket connection and the hub.
func (*Connection) Emit ¶
func (c *Connection) Emit(event string, data any) error
Emit sends a message to this connection.
func (*Connection) On ¶
func (c *Connection) On(event string, handler func(json.RawMessage))
On registers a handler for a specific event type.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub manages active WebSocket connections and rooms.
func (*Hub) BroadcastToRoom ¶
BroadcastToRoom sends a message to all connections in a specific room across all nodes.
func (*Hub) JoinRoom ¶
func (h *Hub) JoinRoom(conn *Connection, room string)
JoinRoom adds a connection to a room.
func (*Hub) LeaveRoom ¶
func (h *Hub) LeaveRoom(conn *Connection, room string)
LeaveRoom removes a connection from a room.
type InboundMessage ¶
type InboundMessage struct {
Event string `json:"event"`
Data json.RawMessage `json:"data"`
}
InboundMessage represents a JSON message from the client.
type Upgrader ¶
type Upgrader struct {
// contains filtered or unexported fields
}
Upgrader handles upgrading HTTP requests to WebSockets.
func NewUpgrader ¶
NewUpgrader creates a new WS upgrader.
func (*Upgrader) Upgrade ¶
func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, userID string) (*Connection, error)
Upgrade upgrades the HTTP request to a WS connection.
Click to show internal directories.
Click to hide internal directories.