sse

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: CC0-1.0 Imports: 7 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 {
	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