Documentation
¶
Overview ¶
Package sse implements a fully concurrent Server-Sent Events library.
Server-sent events is a method of continuously sending data from a server to the browser, rather than repeatedly requesting it.
Examples ¶
Basic usage of sse package.
s := sse.NewServer(nil)
http.Handle("/events/", s)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// RetryInterval change EventSource default retry interval (milliseconds).
RetryInterval int
// Headers allow to set custom headers (useful for CORS support).
Headers map[string]string
// All usage logs end up in Logger
Logger *log.Logger
// Called when a new client appears. Return a set of messages to send before current messages
InitMessages func(ClientLastEventId string, ServerLastEventId string) []Message
}
Options contains configuration for the server
type Server ¶
Server holds the info for a server
func (*Server) GetClientsCount ¶
GetClientsCount outputs the current number of active http connections
func (*Server) LastEventId ¶
LastEventId returns the event id of the last event to have been sent
func (*Server) Restart ¶
func (s *Server) Restart()
Restart closes all clients and allow new connections.
func (*Server) SendMessage ¶
SendMessage broadcast a message to all clients
Click to show internal directories.
Click to hide internal directories.