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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastEvent

func BroadcastEvent(eventType, data string)

BroadcastEvent sends an event to all subscribers

func HandleSSE

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

HandleSSE is the HTTP handler for the SSE endpoint

func RegisterSubscriber

func RegisterSubscriber(s *Subscriber)

RegisterSubscriber adds a subscriber to the global subscribers map

func SendTranscription

func SendTranscription(text string)

SendTranscription broadcasts a transcription result to all subscribers

func UnregisterSubscriber

func UnregisterSubscriber(id string)

UnregisterSubscriber removes a subscriber from the global subscribers map

Types

type Subscriber

type Subscriber struct {
	ID          string
	Writer      http.ResponseWriter
	Flusher     http.Flusher
	Closed      bool
	LastText    string
	ConnectedAt time.Time
	LastEventAt time.Time
	EventsSent  int
	RemoteAddr  string
	UserAgent   string
}

Subscriber represents a connected SSE client

func NewSubscriber

func NewSubscriber(w http.ResponseWriter, r *http.Request) (*Subscriber, error)

NewSubscriber creates a new SSE subscriber

func (*Subscriber) SendEvent

func (s *Subscriber) SendEvent(eventType, data string) error

SendEvent sends an SSE event to the subscriber

Jump to

Keyboard shortcuts

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