events

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package events implements eventing for state variables. It covers multicast and subscription- based eventing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTimeout

func ParseTimeout(t string) (dur time.Duration, err error)

ParseTimeout parses the timeout string that the recipient submitted as part of the subscription request. If the string is not according to the required format an error is returned. As defined in UPnP Device Architecture 2.0, the required format is Second-<number>, where <number> is requested timeout in seconds

func ParseURLs

func ParseURLs(callback string) (urls []*url.URL, err error)

ParseURLs parses the callback string that the recipient submitted as part of the subscription request. If the string is not according to the required format an error is returned. As defined in UPnP Device Architecture 2.0, the required format is <url_1><url_2>...<url_n>, where url_x must be a valid url for x=1, ..., n

Types

type Multicast

type Multicast struct {
	Listener chan StateVar
	// contains filtered or unexported fields
}

Multicast implements event mutlicasting

func NewMulticast

func NewMulticast(wanted []string, bootID *types.BootID) (mul *Multicast, err error)

NewMulticast creates a Multicast instance. wanted contains the list of network interfaces that where configured, booID is a function that returns the current BootID. if no interfaces are configured, all interfaces are used

func (*Multicast) Listen

func (me *Multicast) Listen(ctx context.Context)

Listen listens to changes for state variables and stores them in me.changes

func (*Multicast) Run

func (me *Multicast) Run()

Run triggers regular multicast event messages

func (*Multicast) Stop

func (me *Multicast) Stop()

Stop stops sending regular change events

type StateVar

type StateVar interface {
	Name() string
	String() string
	ServiceType() string
	ServiceVersion() string
	DeviceUDN() string
	ServiceID() string
}

StateVar represents a state variable for eventing (i.e. the functions that are required for eventing)

type Subscription

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

Subscription represents the subscription of one recipient to all evented state variables

func (Subscription) Run

func (me Subscription) Run()

Run implements the main eventing loop: Each eventInterval seconds an event for all state variables is sent until a stop request is received

func (Subscription) Stop

func (me Subscription) Stop()

Stop stops the main event loop for the subscription

type Subscriptions

type Subscriptions map[uuid.UUID]*Subscription

Subscriptions maps subscription ID's to the corresponding subscription

func NewSubscriptionMap

func NewSubscriptionMap() Subscriptions

NewSubscriptionMap does what the name suggests

func (Subscriptions) Add

func (me Subscriptions) Add(dur time.Duration, urls []*url.URL, svs []StateVar) (sid uuid.UUID)

Add adds a new subscription

func (Subscriptions) Remove

func (me Subscriptions) Remove(sid uuid.UUID) (err error)

Remove removes the subscription with the ID sid. In case there's no subscription with that ID, en error is returned

func (Subscriptions) RemoveAll

func (me Subscriptions) RemoveAll()

RemoveAll remove all subscriptions

func (Subscriptions) Renew

func (me Subscriptions) Renew(sid uuid.UUID, dur time.Duration) (err error)

Renew renews the subscription with ID sid. In case there's no subscription with that ID, en error is returned

Jump to

Keyboard shortcuts

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