sse

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: CC0-1.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ID      string
	Channel chan *Message
	Request *http.Request
	Writer  http.ResponseWriter
	Flusher http.Flusher
	// contains filtered or unexported fields
}

Client represents a single connection

type Hub

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

Hub manages all connections

func NewHub

func NewHub(ctx context.Context) *Hub

NewHub creates a new hub

func (*Hub) Broadcast

func (hub *Hub) Broadcast(message *Message)

Broadcast sends a message to all connected clients

func (*Hub) GetClientCount

func (hub *Hub) GetClientCount() int

GetClientCount returns the number of connected clients

func (*Hub) Handle

func (hub *Hub) Handle(w http.ResponseWriter, r *http.Request)

Handle is an HTTP handler for connections

func (*Hub) Run

func (hub *Hub) Run()

Run starts the hub

func (*Hub) SendToClient

func (hub *Hub) SendToClient(clientID string, message *Message) error

SendToClient sends a message to a specific client

func (*Hub) Stop

func (hub *Hub) Stop()

Stop gracefully stops the hub

type Iface

type Iface interface {
	Broadcast(msg *Message)
}

type Message

type Message struct {
	Event string
	Data  interface{}
	ID    string
	Retry int
}

Message represents a message to be sent via

func NewMessage

func NewMessage(event string, data interface{}) *Message

NewMessage creates a new message

Jump to

Keyboard shortcuts

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