parrot: Index | Files

package sse

import ""

Package sse creates a Server-Sent Events "spec" server for the transmission of events to connected clients.


Package Files


type Event Uses

type Event struct {
    Event string
    Data  interface{}

Event represents a single server-sent event. Data will be processed by the JSON marshaller before being sent.

type Server Uses

type Server struct {

    // SendEvent accepts an Event{} to broadcast to clients.
    SendEvent chan *Event
    // contains filtered or unexported fields

Server receives events and broadcasts them to all connected clients.

func New Uses

func New() *Server

New creates a new SSE server, with all required events chans, and starts the client management and events dispatch listener loops.

func (Server) ServeHTTP Uses

func (s Server) ServeHTTP(w http.ResponseWriter, _ *http.Request)

ServeHTTP satifies the http.Handler interface, allowing sse.Server to be passed directly as a handler for http-compliant muxes (muxxi?). It handles the connection set-up for event-streams, and client pool management.

Package sse imports 4 packages (graph) and is imported by 2 packages. Updated 2018-10-16. Refresh now. Tools for package owners.