sse

package module
v0.0.0-...-ac87163 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 10 Imported by: 0

README

Server-Sent Events (SSE)

A Go library for producing and consuming streams of HTTP Server-Sent Events (SSE).

See examples/chatserver.go.

Documentation

Index

Constants

View Source
const (
	ContentType = "text/event-stream"
)

Variables

This section is empty.

Functions

func EventWriter

func EventWriter(w http.ResponseWriter) (io.Writer, error)

Types

type Broadcaster

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

func (*Broadcaster) Add

func (br *Broadcaster) Add(w io.Writer, errc chan<- error)

func (*Broadcaster) Remove

func (br *Broadcaster) Remove(w io.Writer)

func (*Broadcaster) Write

func (br *Broadcaster) Write(data []byte) (int, error)

type Decoder

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

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Buffer

func (dec *Decoder) Buffer(buf []byte, max int)

func (*Decoder) Decode

func (dec *Decoder) Decode(ev *Event) error

func (*Decoder) Err

func (dec *Decoder) Err() error

func (*Decoder) More

func (dec *Decoder) More() bool

type Event

type Event struct {
	Id      string
	Event   string
	RawData string
	Data    interface{}
	Retry   time.Duration
	Comment string
}

func (*Event) WriteTo

func (ev *Event) WriteTo(w io.Writer) (n int64, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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