Documentation
¶
Index ¶
- func HandleSSE(broker *Broker) forge.SSEHandler
- type Broker
- func (b *Broker) AddClient(stream forge.Stream) string
- func (b *Broker) Broadcast(event Event)
- func (b *Broker) BroadcastJSON(eventType EventType, data interface{})
- func (b *Broker) ClientCount() int
- func (b *Broker) Close()
- func (b *Broker) KeepAlive() time.Duration
- func (b *Broker) RemoveClient(id string)
- type Event
- type EventType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleSSE ¶
func HandleSSE(broker *Broker) forge.SSEHandler
HandleSSE returns a forge SSE handler that connects clients to the broker. The handler runs for the lifetime of the client connection, sending keep-alive comments at the configured interval. The broker broadcasts events to all connected clients.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker manages SSE client connections and broadcasts events.
func (*Broker) AddClient ¶
AddClient registers a new SSE stream as a client. Returns the client ID for later removal.
func (*Broker) Broadcast ¶
Broadcast sends an event to all connected clients. Failed sends are logged and the client is removed.
func (*Broker) BroadcastJSON ¶
BroadcastJSON sends a JSON event to all connected clients.
func (*Broker) ClientCount ¶
ClientCount returns the number of connected clients.
func (*Broker) Close ¶
func (b *Broker) Close()
Close shuts down the broker and disconnects all clients.
func (*Broker) RemoveClient ¶
RemoveClient removes a client by ID.