sse

package
v0.0.0-...-edf5a02 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reader

func Reader(body io.ReadCloser, ch MessageChan) error

Reader returns a channel that contains parsed SSE messages.

func WriteMessages

func WriteMessages(w http.ResponseWriter, messageChan chan Message) error

WriteMessages writes SSE formatted messages to the writer

Types

type Broker

type Broker struct {
	// Events are pushed to this channel by the main UDP daemon
	Notifier chan Message
	// contains filtered or unexported fields
}

Broker holds open client connections, listens for incoming events on its Notifier channel and broadcast event data to all registered connections

func NewBroker

func NewBroker() (broker *Broker)

NewBroker creates a Broker.

func (*Broker) CloseClient

func (broker *Broker) CloseClient(ch MessageChan)

CloseClient closes the client channel

type Message

type Message struct {
	Event  string
	Data   string
	Object interface{}
}

Message is a message.

type MessageChan

type MessageChan chan Message

A MessageChan is a channel of channels Each connection sends a channel of bytes to a global MessageChan The main broker listen() loop listens on new connections on MessageChan New event messages are broadcast to all registered connection channels

func StartConnection

func StartConnection(broker *Broker) (MessageChan, error)

StartConnection starts a SSE connection, based on an existing HTTP connection.

Jump to

Keyboard shortcuts

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