Documentation
¶
Index ¶
- Constants
- func AuthenticatedSequenceNumber(ctx context.Context) (uint64, bool)
- func CopyAuthenticatedSequenceNumber(ctx context.Context, r *pool.Message)
- func SetAuthenticatedSequenceNumber(r *pool.Message, sequence uint64)
- func ValidSequenceNumber(oldValue, newValue uint32, lastEventOccurs time.Time, now time.Time) bool
- type Client
- type DoFunc
- type Handler
- func (h *Handler[C]) ForgetObservation(token message.Token) bool
- func (h *Handler[C]) GetObservation(key uint64) (*Observation[C], bool)
- func (h *Handler[C]) GetObservationRequest(token message.Token) (*pool.Message, bool)
- func (h *Handler[C]) Handle(w *responsewriter.ResponseWriter[C], r *pool.Message)
- func (h *Handler[C]) HandleNotification(r *pool.Message) bool
- func (h *Handler[C]) HandleNotificationFrom(r *pool.Message, remoteAddr net.Addr) bool
- func (h *Handler[C]) HandleNotificationOrNext(w *responsewriter.ResponseWriter[C], r *pool.Message) bool
- func (h *Handler[C]) NewObservation(req *pool.Message, observeFunc func(req *pool.Message)) (*Observation[C], error)
- func (h *Handler[C]) SetDebug(debug func(format string, args ...any))
- type HandlerFunc
- type Observation
Constants ¶
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 AuthenticatedSequenceNumber ¶ added in v3.9.0
AuthenticatedSequenceNumber returns the authenticated sequence number attached to a message.
func CopyAuthenticatedSequenceNumber ¶ added in v3.9.0
CopyAuthenticatedSequenceNumber copies authenticated ordering metadata onto a message without replacing the message's context.
func SetAuthenticatedSequenceNumber ¶ added in v3.9.0
SetAuthenticatedSequenceNumber marks a notification with its authenticated, non-wrapping sequence number for ordering by the observation handler.
func ValidSequenceNumber ¶
ValidSequenceNumber implements conditions in https://tools.ietf.org/html/rfc7641#section-3.4
Types ¶
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]) ForgetObservation ¶ added in v3.9.0
ForgetObservation removes a local observation without sending a cancellation request.
func (*Handler[C]) GetObservation ¶
func (h *Handler[C]) GetObservation(key uint64) (*Observation[C], bool)
func (*Handler[C]) GetObservationRequest ¶
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]) HandleNotification ¶ added in v3.7.0
HandleNotification delivers a complete notification only while its observation exists.
func (*Handler[C]) HandleNotificationFrom ¶ added in v3.9.2
HandleNotificationFrom delivers a notification only when the observation has a known peer endpoint that matches remoteAddr. An unknown endpoint or nil remoteAddr fails closed. Use HandleNotification when endpoint validation is not available for the transport.
func (*Handler[C]) HandleNotificationOrNext ¶ added in v3.9.2
func (h *Handler[C]) HandleNotificationOrNext(w *responsewriter.ResponseWriter[C], r *pool.Message) bool
HandleNotificationOrNext delivers a notification to its active observation, or forwards the message to the next handler. It reports whether an observation handled the message.
func (*Handler[C]) NewObservation ¶
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 ¶
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