ssdp

package
v1.4.12 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2016 License: GPL-3.0, BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventAlive = EventType(iota)
	EventUpdate
	EventByeBye
)

Variables

This section is empty.

Functions

func SSDPRawSearch

func SSDPRawSearch(httpu *httpu.HTTPUClient, searchTarget string, maxWaitSeconds int, numSends int) ([]*http.Response, error)

SSDPRawSearch performs a fairly raw SSDP search request, and returns the unique response(s) that it receives. Each response has the requested searchTarget, a USN, and a valid location. maxWaitSeconds states how long to wait for responses in seconds, and must be a minimum of 1 (the implementation waits an additional 100ms for responses to arrive), 2 is a reasonable value for this. numSends is the number of requests to send - 3 is a reasonable value for this.

Types

type Entry

type Entry struct {
	// The address that the entry data was actually received from.
	RemoteAddr string
	// Unique Service Name. Identifies a unique instance of a device or service.
	USN string
	// Notfication Type. The type of device or service being announced.
	NT string
	// Server's self-identifying string.
	Server string
	Host   string
	// Location of the UPnP root device description.
	Location url.URL

	BootID   int32
	ConfigID int32

	SearchPort uint16

	// When the last update was received for this entry identified by this USN.
	LastUpdate time.Time
	// When the last update's cached values are advised to expire.
	CacheExpiry time.Time
}

type EventType added in v1.3.1

type EventType int8

func (EventType) String added in v1.3.1

func (et EventType) String() string

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maintains knowledge of discovered devices and services.

NOTE: the interface for this is experimental and may change, or go away entirely.

func NewRegistry

func NewRegistry() *Registry

func NewServerAndRegistry added in v1.3.1

func NewServerAndRegistry() (*httpu.Server, *Registry)

NewServerAndRegistry is a convenience function to create a registry, and an httpu server to pass it messages. Call ListenAndServe on the server for messages to be processed.

func (*Registry) AddListener added in v1.3.1

func (reg *Registry) AddListener(c chan<- Update)

func (*Registry) GetService added in v1.3.1

func (reg *Registry) GetService(serviceURN string) []*Entry

GetService returns known service (or device) entries for the given service URN.

func (*Registry) RemoveListener added in v1.3.1

func (reg *Registry) RemoveListener(c chan<- Update)

func (*Registry) ServeMessage

func (reg *Registry) ServeMessage(r *http.Request)

ServeMessage implements httpu.Handler, and uses SSDP NOTIFY requests to maintain the registry of devices and services.

type Update added in v1.3.1

type Update struct {
	// The USN of the service.
	USN string
	// What happened.
	EventType EventType
	// The entry, which is nil if the service was not known and
	// EventType==EventByeBye. The contents of this must not be modified as it is
	// shared with the registry and other listeners. Once created, the Registry
	// does not modify the Entry value - any updates are replaced with a new
	// Entry value.
	Entry *Entry
}

Jump to

Keyboard shortcuts

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