client

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: 5 Imported by: 2

Documentation

Overview

Package client implements a server-sent event API client.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSubscribeArgs = errors.New("must provides at leat a channel or a callback func in order to subscribe")

ErrInvalidSubscribeArgs is returned when a client tries to subscribe without a channel or a callback

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 SSEClient

type SSEClient struct {
	Username, Password string
	// contains filtered or unexported fields
}

SSEClient holds the client state

func New

func New(url string) *SSEClient

New initialize a new client

func (*SSEClient) Subscribe

func (c *SSEClient) Subscribe(events chan<- *Event, callback func(*Event) error, filterEvents ...string) error

Subscribe connects to the server-sent event endpoint.

Jump to

Keyboard shortcuts

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