monitor

package
v0.0.0-...-057713a Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSource

type DataSource interface {
	GetDeviceInfo(ctx context.Context) (*controller.DeviceInfo, error)
	GetStatus(ctx context.Context) (*controller.ZoneStatus, error)
	GetPlayInfo(ctx context.Context) (*controller.PlayInfo, error)
	SubscribeEvents(ctx context.Context, port int) error
	GetIP() string
}

type Monitor

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

func Start

func Start(ctx context.Context, conn *net.UDPConn, port int) *Monitor

Start launches a new monitor which will be running until the provided context is done.

func (*Monitor) AddDevice

func (m *Monitor) AddDevice(ctx context.Context, s DataSource) (string, error)

AddDevice starts monitoring the given device and returns its DeviceId on success.

func (*Monitor) RemoveDevice

func (m *Monitor) RemoveDevice(ctx context.Context, did string) error

RemoveDevice wipes a device from the monitored pool.

func (*Monitor) Subscribe

func (m *Monitor) Subscribe(fn SubscribeFunc) (string, error)

Subscribe subscribes the given function to receive device state updates. Returns a token which must be used to call Unsubscribe. fmto

func (*Monitor) Unsubscribe

func (m *Monitor) Unsubscribe(token string) error

Unsubscribe returns the given token (returned previously by Subscribe()) from the pool of notified functions.

type Status

type Status struct {
	Power            string   `json:"power"`
	Input            string   `json:"input"`
	Mute             bool     `json:"mute"`
	Volume           uint32   `json:"volume"`
	Artist           string   `json:"artist"`
	Album            string   `json:"album"`
	Track            string   `json:"track"`
	Playback         string   `json:"playback"`
	PlayTime         int64    `json:"play_time"`
	Repeat           string   `json:"repeat"`
	RepeatAvailable  []string `json:"repeat_available"`
	Shuffle          string   `json:"shuffle"`
	ShuffleAvailable []string `json:"shuffle_available"`
	ArtworkURL       string   `json:"artwork_url"`
	SeekForwardStep  int64    `json:"seek_forward"`
	SeekBackwardStep int64    `json:"seek_backward"`
}

Status is the exported device status.

type SubscribeFunc

type SubscribeFunc func(did, ip string, s Status)

Jump to

Keyboard shortcuts

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