SendResponse Method

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

Syntax

ANSI (Cross Platform)
int SendResponse(const char* lpszRequestId);

Unicode (Windows)
INT SendResponse(LPCWSTR lpszRequestId);
- (void)sendResponse:(NSString*)requestId;
#define MID_COAP_SENDRESPONSE 12

IPWORKSIOT_EXTERNAL int IPWORKSIOT_CALL IPWorksIoT_CoAP_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

Remarks

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).

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

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