Documentation ¶
Overview ¶
Package server lets you interact with existing devices
Index ¶
- Constants
- type Device
- type FakeDevice
- func (f *FakeDevice) Exists() bool
- func (f *FakeDevice) Feature(name string) Feature
- func (f *FakeDevice) Features() []Feature
- func (f *FakeDevice) Id() string
- func (f *FakeDevice) Info() *device.Info
- func (f *FakeDevice) IsReachable() bool
- func (f *FakeDevice) Manufacturer() string
- func (f *FakeDevice) Model() string
- func (f *FakeDevice) Name() string
- func (f *FakeDevice) SerialNumber() string
- func (f *FakeDevice) Type() string
- type Feature
- type Handler
- type Manager
- func (m *Manager) Device(topic string) Device
- func (m *Manager) DeviceByType(t string) []Device
- func (m *Manager) Devices() []Device
- func (m *Manager) HasDevice(topic string) bool
- func (m *Manager) SetHandler(handler Handler)
- func (m *Manager) SetUpdateChannel(ch chan<- Update)
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) WaitForDevice(ctx context.Context, topic string) Device
- type Transport
- type Update
- type UpdateType
Constants ¶
const ( AddedDevice = "added" UpdatedDevice = "updated" RemovedDevice = "removed" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device interface { // Common contains the common methods for client and server device.Common // Feature returns the feature with server functions (Set(), OnUpdate()) available. // Fetching a feature that doesn't exist will _NOT_ return nil, but instead create // a *feature.Fake. To check if feature actually exists; call Feature("name").Exists() Feature(name string) Feature // Exists returns true if the device exists Exists() bool // Features returns a slice of available features Features() []Feature // IsReachable returns true if device is online IsReachable() bool // Info returns the original device info Info() *device.Info // contains filtered or unexported methods }
Device is used by applications that monitor or send commands to the different client devices. For examples an application that integrates with a personal assistant
type FakeDevice ¶
func (*FakeDevice) Exists ¶
func (f *FakeDevice) Exists() bool
func (*FakeDevice) Feature ¶
func (f *FakeDevice) Feature(name string) Feature
func (*FakeDevice) Features ¶
func (f *FakeDevice) Features() []Feature
func (*FakeDevice) Id ¶
func (f *FakeDevice) Id() string
func (*FakeDevice) Info ¶
func (f *FakeDevice) Info() *device.Info
func (*FakeDevice) IsReachable ¶
func (f *FakeDevice) IsReachable() bool
func (*FakeDevice) Manufacturer ¶
func (f *FakeDevice) Manufacturer() string
func (*FakeDevice) Model ¶
func (f *FakeDevice) Model() string
func (*FakeDevice) Name ¶
func (f *FakeDevice) Name() string
func (*FakeDevice) SerialNumber ¶
func (f *FakeDevice) SerialNumber() string
func (*FakeDevice) Type ¶
func (f *FakeDevice) Type() string
type Handler ¶
type Handler interface { AddedDevice(Device) UpdatedDevice(Device, []*device.InfoUpdate) RemovedDevice(Device) }
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager holds all the devices and deals with updating device state as it receives it from the transport
func (*Manager) DeviceByType ¶
DeviceByType returns all devices known to the manager of type t.
func (*Manager) SetHandler ¶
SetHandler is a wrapper around SetUpdateChannel for use with callbacks instead of channels, the handler is called synchronously
func (*Manager) SetUpdateChannel ¶
SetUpdateChannel registers a channel that will receive Update when a device is added, removed or changed.
type Transport ¶
type Transport interface { // DeviceState receives a device.Info on announce, leave or update DeviceState() chan *device.State device.Transport }
Transport is the server's transport
type Update ¶
type Update struct { Type UpdateType Device Device Changes []*device.InfoUpdate }
type UpdateType ¶
type UpdateType string