sse

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleSSE

func HandleSSE(w http.ResponseWriter, r *http.Request, client *Client) error

HandleSSE handles the SSE connection for a client

Types

type Client

type Client struct {
	ID      string
	Events  chan Event
	Done    chan struct{}
	Request *http.Request
}

Client represents a connected SSE client

type Event

type Event struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

Event represents a server-sent event

type EventBus

type EventBus struct {
	Register   chan *Client
	Unregister chan *Client
	// contains filtered or unexported fields
}

EventBus manages all SSE clients and message distribution

func NewEventBus

func NewEventBus() *EventBus

NewEventBus creates a new event bus instance

func (*EventBus) GetClient

func (eb *EventBus) GetClient(id string) (*Client, bool)

GetClient returns a client by ID

func (*EventBus) Run

func (eb *EventBus) Run()

Run starts the event bus loop

Jump to

Keyboard shortcuts

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