observation

package
v3.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ObservationSequenceTimeout = 128 * time.Second

ObservationSequenceTimeout defines how long is sequence number is valid. https://tools.ietf.org/html/rfc7641#section-3.4

Variables

This section is empty.

Functions

func ValidSequenceNumber

func ValidSequenceNumber(oldValue, newValue uint32, lastEventOccurs time.Time, now time.Time) bool

ValidSequenceNumber implements conditions in https://tools.ietf.org/html/rfc7641#section-3.4

Types

type Client

type Client interface {
	Context() context.Context
	WriteMessage(req *pool.Message) error
	ReleaseMessage(msg *pool.Message)
	AcquireMessage(ctx context.Context) *pool.Message
}

type DoFunc

type DoFunc = func(req *pool.Message) (*pool.Message, error)

type Handler

type Handler[C Client] struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler[C Client](cc C, next HandlerFunc[C], do DoFunc) *Handler[C]

func (*Handler[C]) GetObservation

func (h *Handler[C]) GetObservation(key uint64) (*Observation[C], bool)

func (*Handler[C]) GetObservationRequest

func (h *Handler[C]) GetObservationRequest(token message.Token) (*pool.Message, bool)

GetObservationRequest returns observation request for token

func (*Handler[C]) Handle

func (h *Handler[C]) Handle(w *responsewriter.ResponseWriter[C], r *pool.Message)

func (*Handler[C]) NewObservation

func (h *Handler[C]) NewObservation(req *pool.Message, observeFunc func(req *pool.Message)) (*Observation[C], error)

type HandlerFunc

type HandlerFunc[C Client] func(*responsewriter.ResponseWriter[C], *pool.Message)

The HandlerFunc type is an adapter to allow the use of ordinary functions as COAP handlers.

type Observation

type Observation[C Client] struct {
	// contains filtered or unexported fields
}

Observation represents subscription to resource on the server

func (*Observation[C]) Cancel

func (o *Observation[C]) Cancel(ctx context.Context, opts ...message.Option) error

Cancel remove observation from server. For recreate observation use Observe.

func (*Observation[C]) Canceled

func (o *Observation[C]) Canceled() bool

func (*Observation[C]) Request

func (o *Observation[C]) Request() message.Message

Jump to

Keyboard shortcuts

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