Documentation
¶
Overview ¶
Package upnpsub handles subscribing to UPnP events. It tries to follow section 4 of "UPnP Device Architecture 1.0".
Index ¶
Constants ¶
View Source
const ( DefaultPort = 8058 // DefaultPort is the port that the HTTP server listens on. DefaultURI = "/eventSub" // DefaultURI is the default URI where the UPnP publisher sends notify requests. )
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶ added in v0.5.0
func ListenAndServe(host string, cp ControlPoint) error
ListenAndServe is a wrapper for http.ListenAndServe.
Types ¶
type ControlPoint ¶
type ControlPoint interface {
// ServeHTTP handles HTTP notify requests from UPnP event publishers.
ServeHTTP(http.ResponseWriter, *http.Request)
// URI returns the URI that the ControlPoint has to be mounted on.
URI() string
// Port returns the port that the ControlPoint has to listens on.
Port() int
// Subscribe to event publisher and return a Subscription.
// Subscription is unsubscribed when the provided context is done.
// ControlPoint must be listening before calling this function.
Subscribe(ctx context.Context, eventURL *url.URL) (Subscription, error)
}
ControlPoint handles the HTTP notify requests and keeps track of subscriptions.
func NewControlPoint ¶
func NewControlPoint(opts ...func(cp *controlPoint)) ControlPoint
NewControlPoint creates a new ControlPoint.
type Property ¶
type Property struct {
Name string // Name of inner field from UPnP property.
Value string // Value of inner field from UPnP property.
}
Property is the notify request's property.
type Subscription ¶
type Subscription interface {
// Events returns channel that receives events from the UPnP event publisher. Should only be consumed by one goroutine.
Events() <-chan *Event
// Renew queues an early subscription renewal.
Renew()
// IsActive returns true if the subscription is active.
IsActive() bool
// LastActive returns the time the subscription was last active.
LastActive() time.Time
// Done returns channel that signals when the subscription is done cleaning up after the context was canceled.
Done() <-chan struct{}
}
Subscription represents a subscription to UPnP event publisher.
Click to show internal directories.
Click to hide internal directories.