server

package
v0.0.0-...-1949828 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2018 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package server implements a server-sent event API server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Event string // Type of the event (i.e. "hearbeat", or you custom event type)
	Data  []byte // Data field
}

Event holds the event fields

type SSEServer

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

SSEServer holds the broker and implement the http.Handler interface

func New

func New() *SSEServer

New initialize a new server

func (*SSEServer) Events

func (s *SSEServer) Events() chan<- *Event

Events returns the channel as send-only, that can be used to publish events

func (*SSEServer) Publish

func (s *SSEServer) Publish(event string, data []byte)

Publish publishes an event

func (*SSEServer) ServeHTTP

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

ServeHTTP implements HandlerFunc

func (*SSEServer) Start

func (s *SSEServer) Start()

Start start the broker and the heartbeat goroutine

Jump to

Keyboard shortcuts

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