Documentation
¶
Index ¶
- type Event
- type Hub
- func (hub *Hub) AddSwitch(r sw.Switcher) error
- func (hub *Hub) Broadcast(dev sw.Device)
- func (hub *Hub) BroadcastToWsClients(event Event) error
- func (hub *Hub) ListenHTTP(host string, port int, errorCh chan<- struct{})
- func (hub *Hub) RemoveSwitch(r sw.Switcher)
- func (hub *Hub) Switch(name string) (sw.Switcher, bool)
- func (hub *Hub) Switches() []sw.Switcher
- type SwitchEvent
- type WsClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { Name SwitchEvent `json:"name,omitempty"` DeviceName string `json:"device_name,omitempty"` Device sw.Device `json:"device,omitempty"` //only used for updates }
type Hub ¶
Hub is a struct which makes a switch available through http.
func (*Hub) BroadcastToWsClients ¶
BroadcastToWsClients will send a rotator.Status struct to all clients connected through a Websocket
func (*Hub) ListenHTTP ¶
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) RemoveSwitch ¶
RemoveSwitch deletes / de-registers a switch.
type SwitchEvent ¶
type SwitchEvent string
const ( AddSwitch SwitchEvent = "add" RemoveSwitch SwitchEvent = "remove" UpdateSwitch SwitchEvent = "update" )
Click to show internal directories.
Click to hide internal directories.