discovery

package
v0.0.0-...-531a2f0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package discovery is used to discover devices on the network using a provided scanner

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDevice

func NewDevice(ip net.IP, port int, properties []string) *chromecast.Device

NewDevice returns an new chromecast device

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

func WithID

func WithID(id string) DeviceMatcher

WithID matches a device by its id

func WithName

func WithName(name string) DeviceMatcher

WithName matches a device by its name

func WithType

func WithType(t string) DeviceMatcher

WithType matches a device by its type

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

Directories

Path Synopsis
Package zeroconf provides a Scanner backed by the github.com/grandcat/zeroconf package
Package zeroconf provides a Scanner backed by the github.com/grandcat/zeroconf package

Jump to

Keyboard shortcuts

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