websocket

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

Conn wraps a websocket connection.

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

Hub holds connected clients and broadcasts (plan: realtime chat, notifications).

func NewHub

func NewHub() *Hub

NewHub returns a new hub. Call Run() to start.

func (*Hub) Broadcast

func (h *Hub) Broadcast(msg []byte)

Broadcast sends a message to all connected clients.

func (*Hub) Run

func (h *Hub) Run()

Run runs the hub (blocks). Call in a goroutine.

func (*Hub) SetAllowedOrigins

func (h *Hub) SetAllowedOrigins(origins []string)

SetAllowedOrigins configures allowed websocket origins. When empty, same-origin requests are allowed by default.

func (*Hub) Upgrade

func (h *Hub) Upgrade(w http.ResponseWriter, r *http.Request) (*Conn, error)

Upgrade upgrades the HTTP request to WebSocket and registers the conn with the hub.

Jump to

Keyboard shortcuts

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