server

package
v0.0.0-...-d6813a9 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Echo

func Echo(w http.ResponseWriter, r *http.Request)

func Home

func Home(w http.ResponseWriter, r *http.Request)

Types

type Device

type Device struct {
	types.Device
	Conn *websocket.Conn `json:"-"`
}

type DeviceHandler

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

func (*DeviceHandler) GetDeivce

func (h *DeviceHandler) GetDeivce(w http.ResponseWriter, r *http.Request)

func (*DeviceHandler) GetDeviceState

func (h *DeviceHandler) GetDeviceState(w http.ResponseWriter, r *http.Request)

func (*DeviceHandler) GetDevices

func (h *DeviceHandler) GetDevices(w http.ResponseWriter, r *http.Request)

func (*DeviceHandler) Root

func (h *DeviceHandler) Root(w http.ResponseWriter, r *http.Request)

func (*DeviceHandler) SetDeviceState

func (h *DeviceHandler) SetDeviceState(w http.ResponseWriter, r *http.Request)

func (*DeviceHandler) SetRoutes

func (h *DeviceHandler) SetRoutes(r *mux.Router)

type DeviceService

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

func NewDeviceService

func NewDeviceService(serviceIp string, servicePort int, websocketPort int, devices *Devices) *DeviceService

func (*DeviceService) ServeHTTPS

func (s *DeviceService) ServeHTTPS()

type Devices

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

func NewDeviceStore

func NewDeviceStore() *Devices

func (*Devices) AddOrUpdateDevice

func (ds *Devices) AddOrUpdateDevice(d *Device)

TODO: improve

func (*Devices) Get

func (ds *Devices) Get(id string) (*Device, bool)

func (*Devices) ListDevices

func (ds *Devices) ListDevices() []*Device

func (*Devices) TurnOff

func (ds *Devices) TurnOff(id string) (*types.Device, error)

func (*Devices) TurnOn

func (ds *Devices) TurnOn(id string) (*types.Device, error)

TODO: move to upper layer

type WsServer

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

func NewWsServer

func NewWsServer(port int, devices *Devices) *WsServer

func (*WsServer) Ack

func (ws *WsServer) Ack(msg *types.Message) ([]byte, error)

func (*WsServer) Date

func (ws *WsServer) Date(msg *types.Message) ([]byte, error)

func (*WsServer) Query

func (ws *WsServer) Query(payload []byte) ([]byte, error)

func (*WsServer) Register

func (ws *WsServer) Register(msg *types.Message, conn *websocket.Conn) ([]byte, error)

func (*WsServer) Serve

func (ws *WsServer) Serve()

func (*WsServer) ServeHTTP

func (ws *WsServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*WsServer) Update

func (ws *WsServer) Update(payload []byte, conn *websocket.Conn) ([]byte, error)

Jump to

Keyboard shortcuts

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