Documentation ¶
Index ¶
Constants ¶
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 is deprecated; use SSDPRawSearchCtx instead
func SSDPRawSearchCtx ¶
func SSDPRawSearchCtx(ctx context.Context, 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 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 ¶
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 ¶
func (*Registry) GetService ¶
GetService returns known service (or device) entries for the given service URN.
func (*Registry) RemoveListener ¶
func (*Registry) ServeMessage ¶
ServeMessage implements httpu.Handler, and uses SSDP NOTIFY requests to maintain the registry of devices and services.
type Update ¶
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 }