hub

package
Version: v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Name        RotatorEvent    `json:"name,omitempty"`
	RotatorName string          `json:"rotator_name,omitempty"`
	Heading     rotator.Heading `json:"heading,omitempty"`
}

type Hub

type Hub struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Hub is a struct which makes a rotator available through network interfaces, supporting several protocols.

func NewHub

func NewHub(rotators ...rotator.Rotator) (*Hub, error)

NewHub returns the pointer to an initialized Hub object.

func (*Hub) AddRotator

func (hub *Hub) AddRotator(r rotator.Rotator) error

AddRotator adds / registers a rotator. The rotator's name must be unique.

func (*Hub) Broadcast

func (hub *Hub) Broadcast(ev Event)

Broadcast sends a rotator event to all connected clients

func (*Hub) ListenHTTP

func (hub *Hub) ListenHTTP(host string, port int, errorCh chan<- struct{})

ListenHTTP starts a HTTP Server on a given network adapter / port and sets a HTTP and Websocket handler. Since this function contains an endless loop, it should be executed in a go routine. If the listener can not be initialized, it will close the errorCh channel.

func (*Hub) ListenTCP

func (hub *Hub) ListenTCP(host string, port int, tcpError chan<- bool)

ListenTCP starts a TCP listener on a given network adapter / port. Since this function contains an endless loop, it should be executed in a go routine. If the listener can not be initialized, it will close the tcpError channel.

func (*Hub) RemoveRotator

func (hub *Hub) RemoveRotator(r rotator.Rotator)

RemoveRotator deletes / de-registers a rotator.

func (*Hub) Rotator

func (hub *Hub) Rotator(name string) (rotator.Rotator, bool)

Rotator returns a particular rotator stored from the hub. If no rotator exists with that name, (nil, false) will be returned.

func (*Hub) Rotators

func (hub *Hub) Rotators() []rotator.Rotator

Rotators returns a slice of all registered rotators.

type RotatorEvent

type RotatorEvent string
const (
	AddRotator    RotatorEvent = "add"
	RemoveRotator RotatorEvent = "remove"
	UpdateHeading RotatorEvent = "heading"
)

type TCPClient

type TCPClient struct {
	net.Conn
}

TCPClient is a wrapper for clients connected through plain a TCP socket.

type WsClient

type WsClient struct {
	*websocket.Conn
}

WsClient is a wrapper for clients connected through a Websocket

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL