IPWorks IoT 2020 JavaScript Edition

Questions / Feedback?

SendResponse Method

Sends a response for a given pending request to the corresponding client.


async coap.sendResponse(requestId : string): Promise<void>


This method sends a response for the request in the PendingRequest* properties identified by RequestId. The ResponseData property specifies the data that will be sent in the response, and the ResponseCode property specifies the response code. If the ResponseContentFormat and/or ResponseETag properties are non-empty, their values will be used to include Content-Format and Etag options in the response (respectively). Any additional options present in the ResponseOption* properties will be included as well.

If the UseConfirmableMessages property is enabled when this method is called, the class will automatically retransmit the response message (if necessary) until it receives confirmation from the client that it was received. Note that the retransmission period is not infinite; eventually the class will assume that the message is undeliverable and time out the response. The ResponseComplete event will fire once the message receipt is confirmed (or once the retransmission period elapses).

If the UseConfirmableMessages property is disabled, the ResponseComplete event will fire immediately instead, since there is no way to know whether the client received the response.

Note: This method can only be called 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]