sse: github.com/julienschmidt/sse Index | Files

package sse

import "github.com/julienschmidt/sse"

Package sse provides HTML5 Server-Sent Events for Go.

See http://www.w3.org/TR/eventsource/ for the technical specification

Index

Package Files

sse.go

type Streamer Uses

type Streamer struct {
    // contains filtered or unexported fields
}

Streamer receives events and broadcasts them to all connected clients. Streamer is a http.Handler. Clients making a request to this handler receive a stream of Server-Sent Events, which can be handled via JavaScript. See the linked technical specification for details.

func New Uses

func New() *Streamer

New returns a new initialized SSE Streamer

func (*Streamer) BufSize Uses

func (s *Streamer) BufSize(size uint)

BufSize sets the event buffer size for new clients.

func (*Streamer) SendBytes Uses

func (s *Streamer) SendBytes(id, event string, data []byte)

SendBytes sends an event with the given byte slice interpreted as a string as the data value to all connected clients. If the id or event string is empty, no id / event type is send.

func (*Streamer) SendInt Uses

func (s *Streamer) SendInt(id, event string, data int64)

SendInt sends an event with the given int as the data value to all connected clients. If the id or event string is empty, no id / event type is send.

func (*Streamer) SendJSON Uses

func (s *Streamer) SendJSON(id, event string, v interface{}) error

SendJSON sends an event with the given data encoded as JSON to all connected clients. If the id or event string is empty, no id / event type is send.

func (*Streamer) SendString Uses

func (s *Streamer) SendString(id, event, data string)

SendString sends an event with the given data string to all connected clients. If the id or event string is empty, no id / event type is send.

func (*Streamer) SendUint Uses

func (s *Streamer) SendUint(id, event string, data uint64)

SendUint sends an event with the given unsigned int as the data value to all connected clients. If the id or event string is empty, no id / event type is send.

func (*Streamer) ServeHTTP Uses

func (s *Streamer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler interface.

Package sse imports 5 packages (graph) and is imported by 2 packages. Updated 2019-09-22. Refresh now. Tools for package owners.