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
Click to show internal directories.
Click to hide internal directories.