Documentation ¶
Overview ¶
Package discovery is used to discover devices on the network using a provided scanner
Index ¶
- func NewDevice(ip net.IP, port int, properties []string) *chromecast.Device
- func Uniq(in <-chan *chromecast.Device, out chan<- *chromecast.Device)
- type DeviceMatcher
- type Scanner
- type Service
- func (s Service) First(ctx context.Context, matchers ...DeviceMatcher) (*chromecast.Device, error)
- func (s Service) Sorted(ctx context.Context, matchers ...DeviceMatcher) ([]*chromecast.Device, error)
- func (s Service) Uniq(ctx context.Context, matchers ...DeviceMatcher) (map[string]*chromecast.Device, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Uniq ¶
func Uniq(in <-chan *chromecast.Device, out chan<- *chromecast.Device)
Uniq forward all client deduplicated
Types ¶
type DeviceMatcher ¶
type DeviceMatcher func(*chromecast.Device) bool
DeviceMatcher allows to specicy which device should be accepted
type Scanner ¶
type Scanner interface {
Scan(ctx context.Context, results chan<- *chromecast.Device) error
}
Scanner scans for chromecast and pushes them onto the results channel (eventually multiple times) It must return immediately and scan in a different goroutine The results channel must be closed when the ctx is done
type Service ¶
type Service struct {
Scanner Scanner
}
Service allows to discover chromecast via the given scanner
func (Service) First ¶
func (s Service) First(ctx context.Context, matchers ...DeviceMatcher) (*chromecast.Device, error)
First returns the first chromecast that is discovered by the scanner (matching all matchers - if any)
func (Service) Sorted ¶
func (s Service) Sorted(ctx context.Context, matchers ...DeviceMatcher) ([]*chromecast.Device, error)
Sorted scans until cancellation of the context and returns a sorted list of chromecast devices
func (Service) Uniq ¶
func (s Service) Uniq(ctx context.Context, matchers ...DeviceMatcher) (map[string]*chromecast.Device, error)
Uniq scans until cancellation of the context and returns a map of chromecast devices by ID