SendNotification Method

Sends a notification to all clients observing a given resource.

Syntax

ANSI (Cross Platform)
int SendNotification(const char* lpszURI);

Unicode (Windows)
INT SendNotification(LPCWSTR lpszURI);
- (void)sendNotification:(NSString*)URI;
#define MID_COAP_SENDNOTIFICATION 11

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 notification to all clients observing the resource identified by URI, notifying them of its latest state. Clients should be notified whenever a resource's content changes (or periodically, if it changes very often) by sending a 2.xx response code; typically 2.03 "Valid" or 2.05 "Content". Clients should also be notified if a resource can no longer be observed (e.g., when it is deleted) by sending a notification with a non-2.xx response code (e.g., 4.04 "Not Found"). The class will automatically unregister all observers when a non-2.xx notification is sent.

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.

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]