RequestComplete Event

Fires when a request completes.

Syntax

ANSI (Cross Platform)
virtual int FireRequestComplete(CoAPRequestCompleteEventParams *e);
typedef struct {
int Method;
const char *URI;
const char *RequestId;
int ErrorCode;
const char *ErrorDescription; int reserved; } CoAPRequestCompleteEventParams; Unicode (Windows) virtual INT FireRequestComplete(CoAPRequestCompleteEventParams *e);
typedef struct {
INT Method;
LPCWSTR URI;
LPCWSTR RequestId;
INT ErrorCode;
LPCWSTR ErrorDescription; INT reserved; } CoAPRequestCompleteEventParams;
- (void)onRequestComplete:(int)method :(NSString*)URI :(NSString*)requestId :(int)errorCode :(NSString*)errorDescription;
#define EID_COAP_REQUESTCOMPLETE 6

virtual INT IPWORKSIOT_CALL FireRequestComplete(INT &iMethod, LPSTR &lpszURI, LPSTR &lpszRequestId, INT &iErrorCode, LPSTR &lpszErrorDescription);

Remarks

This event fires when a request completes. Usually, a request is considered complete when a response has been received. However, requests can also be considered "complete" if either of the following occurs:

  • If the UseConfirmableMessages property is enabled, and the class did not receive confirmation that the request was received before the retransmission period elapsed.
  • If Timeout property is greater than 0, and the class did not receive a response before the timeout period elapsed.

Assuming a response was received (i.e., the ErrorCode parameter is either 0 or 709; see below), then the response code, payload, and options can be obtained by querying the ResponseCode, ResponseData, ResponseContentFormat, ResponseETag, and ResponseOption* properties.

The Method parameter reflects the request method code. The following table provides a (non-exhaustive) list of some of the more common method codes; refer to the IANA's CoAP Method Codes registry for a full list.

Method Code Name
1 GET
2 POST
3 PUT
4 DELETE
5 FETCH
6 PATCH

The URI parameter reflects the requested resource's URI.

The ErrorCode parameter indicates whether the request encountered an error. If no error was encountered, it will be 0; if the server returned a non-2.xx response code, it will be 709; if some other error occurred (e.g., the request timed out), it will be another non-zero value.

The ErrorDescription parameter provides a description of the error that occurred (or, if ErrorCode is 709, a string version of the response code returned by the server). It will be empty if no error was encountered.

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

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