IPWorks IoT 2020 JavaScript Edition

Questions / Feedback?

Register Event

Fires when a client wishes to register for notifications.


coap.on('Register', listener: (e: {readonly remoteHost: string, readonly remotePort: number, readonly URI: string, readonly URIHost: string, readonly URIPort: number, readonly URIPath: string, readonly URIQuery: string, readonly token: string, readonly tokenB: Uint8Array, accept: boolean}) => void )


This event fires anytime a client wishes to register itself as an observer for the resource identified by URI. Refer to the StartObserving and SendNotification methods, as well as the Notification event, for more information about observing resources and resource change notifications.

Any options included in the request can be obtained by querying the RequestOption* properties.

To correctly handle this event, populate the ResponseCode, ResponseData, ResponseContentFormat, ResponseETag, and ResponseOption* properties as desired before this event finishes. (This must be done regardless of the Accept parameter's final value; see below for more information on why).

The RemoteHost parameter reflects the client's IP address or hostname.

The RemotePort parameter reflects the client's port.

The URI parameter reflects the exact resource URI that the client wishes to observe (the CoAP specification states that the full URI must be used to track observers). This value must be passed exactly as-is to the SendNotification method to notify observers of changes to the resource.

The URIHost, URIPort, URIPath, and URIQuery parameters are provided for additional convenience

The Token parameter reflects the token included in the registration request.

The Accept parameter specifies whether the class should accept the registration. By default, it is False, and the request will be treated like a normal GET request. Setting it to True will cause the class to add the client to its internal list of registered observers for the specified URI.

Note: This event is only used when the class is operating in server mode (i.e., when the Listening property is enabled).

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 JavaScript Edition - Version 20.0 [Build 8265]