websocket

package
v0.3.2-alpha Latest Latest
Warning

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

Go to latest
Published: May 1, 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 Client

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

Client represents a websocket client

func NewClient

func NewClient(conn *websocket.Conn) *Client

NewClient creates a new client

func (*Client) ReadPump

func (c *Client) ReadPump(hub *Hub)

ReadPump pumps messages from the websocket connection to the hub

func (*Client) WritePump

func (c *Client) WritePump()

WritePump pumps messages from the hub to the websocket connection

type Hub

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

Hub maintains the set of active clients and broadcasts messages to them

func NewHub

func NewHub() *Hub

NewHub creates a new Hub

func (*Hub) Broadcast

func (h *Hub) Broadcast(message interface{}) error

Broadcast sends a message to all connected clients

func (*Hub) BroadcastProgress

func (h *Hub) BroadcastProgress(msg *ProgressMessage) error

BroadcastProgress sends a progress update to all clients

func (*Hub) Register

func (h *Hub) Register(client *Client)

Register registers a new client

func (*Hub) Run

func (h *Hub) Run(ctx context.Context)

Run starts the hub's main loop

func (*Hub) Unregister

func (h *Hub) Unregister(client *Client)

Unregister unregisters a client

type ProgressMessage

type ProgressMessage struct {
	JobID     string  `json:"job_id"`
	FileIndex int     `json:"file_index"`
	FilePath  string  `json:"file_path"`
	Status    string  `json:"status"`
	Progress  float64 `json:"progress"`
	Message   string  `json:"message"`
	Error     string  `json:"error,omitempty"`
}

ProgressMessage represents a progress update message

Jump to

Keyboard shortcuts

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