events

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: GPL-3.0 Imports: 16 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 Eventing added in v0.2.1

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

Eventing implements multicast and subscription based eventing as specified in the UPnP device architecture 2.0

func NewEventing added in v0.2.1

func NewEventing(wanted []string, bootID *types.BootID) (evt *Eventing, err error)

NewEventing creates an Eventing 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 (*Eventing) AddSub added in v0.2.1

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

AddSub adds a new subscription

func (*Eventing) Listen added in v0.2.1

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

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

func (*Eventing) RemoveAllSubs added in v0.2.1

func (me *Eventing) RemoveAllSubs()

RemoveAllSubs remove all subscriptions

func (*Eventing) RemoveSub added in v0.2.1

func (me *Eventing) RemoveSub(sid uuid.UUID) (err error)

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

func (*Eventing) RenewSub added in v0.2.1

func (me *Eventing) RenewSub(sid uuid.UUID, dur time.Duration) (err error)

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

func (*Eventing) Run added in v0.2.1

func (me *Eventing) Run()

Run implemente the main eventing loop and triggers event sending (if necessary - i.e. if state variable were changed)

func (*Eventing) Stop added in v0.2.1

func (me *Eventing) Stop()

Stop stops sending regular change events

type StateVar

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

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

Jump to

Keyboard shortcuts

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