app

package
v0.0.0-...-dc9d1ec Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package app contains helper functions to create application and drivers

Drivers are standalone applications that control devices. A driver is an app which registers its' devices to the inventory and responds to commands to devices under its' control

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID   string
	Log  log.Logger
	Name string

	Broker *mqtt.ClientConn

	Signal chan os.Signal
	// contains filtered or unexported fields
}

App is a helper to create a driver or application. It takes away the burden of (un)registering devices at startup and responding to discovery messages.

func NewApp

func NewApp(name string) (*App, error)

NewApp returns an app in the 'app' namespace

func NewCore

func NewCore(name string) (*App, error)

NewCore returns an app in the 'core' namespace

func NewDriver

func NewDriver(name string) (*App, error)

NewDriver returns an app in the 'driver' namespace

func (*App) Debug

func (app *App) Debug() bool

Debug will return the debug status of the app

func (*App) DeviceList

func (app *App) DeviceList() []*message.Device

DeviceList will return the list of devices

func (*App) FilterMessages

func (app *App) FilterMessages(b bool)

FilterMessages allows the app to control automatic message filtering By default messages are filtered

func (*App) GCDeviceList

func (app *App) GCDeviceList(t time.Time)

GCDeviceList will remove all devices older then time t

func (*App) NewDevice

func (app *App) NewDevice(name string) *message.Device

NewDevice returns a new Device with the given name.

func (*App) Publish

func (app *App) Publish(topic queue.Topic, m message.Message)

Publish will send a message to the specified topic.

func (*App) Register

func (app *App) Register(devices ...*message.Device)

Register will set the devices controlled by this app.

func (*App) RegisterAll

func (app *App) RegisterAll(to string)

RegisterAll will send the Register message to the inventory.

func (*App) SetHandler

func (app *App) SetHandler(topic queue.Topic, handler message.Handler)

SetHandler will set the message handler

func (*App) Start

func (app *App) Start() (err error)

Start starts this app. It connects to the message hub and registers devices. It also starts a goroutine to respond to discovery messages.

func (*App) Stop

func (app *App) Stop()

Stop will stop this app. It will stop the discovery goroutine, disconnect from the message hub and close its connection.

func (*App) Unregister

func (app *App) Unregister(devices ...*message.Device)

Unregister will remove the devices from this app.

func (*App) UnregisterAll

func (app *App) UnregisterAll(to string)

UnregisterAll will unregister all devices from the inventory. This is usually done on shutdown.

func (*App) Wait

func (app *App) Wait()

Wait will wait for an os.Signal to return

Jump to

Keyboard shortcuts

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