[][src]Type Definition paho_mqtt_sys::MQTTAsync_messageArrived

type MQTTAsync_messageArrived = Option<unsafe extern "C" fn(context: *mut c_void, topicName: *mut c_char, topicLen: c_int, message: *mut MQTTAsync_message) -> c_int>;

This is a callback function. The client application must provide an implementation of this function to enable asynchronous receipt of messages. The function is registered with the client library by passing it as an argument to MQTTAsync_setCallbacks(). It is called by the client library when a new message that matches a client subscription has been received from the server. This function is executed on a separate thread to the one on which the client application is running.

Note: Neither MQTTAsync_create() nor MQTTAsync_destroy() should be called within this callback. @param context A pointer to the context value originally passed to MQTTAsync_setCallbacks(), which contains any application-specific context. @param topicName The topic associated with the received message. @param topicLen The length of the topic if there are one more NULL characters embedded in topicName, otherwise topicLen is 0. If topicLen is 0, the value returned by strlen(topicName) can be trusted. If topicLen is greater than 0, the full topic name can be retrieved by accessing topicName as a byte array of length topicLen. @param message The MQTTAsync_message structure for the received message. This structure contains the message payload and attributes. @return This function must return 0 or 1 indicating whether or not the message has been safely received by the client application.
Returning 1 indicates that the message has been successfully handled. To free the message storage, ::MQTTAsync_freeMessage must be called. To free the topic name storage, ::MQTTAsync_free must be called.
Returning 0 indicates that there was a problem. In this case, the client library will reinvoke MQTTAsync_messageArrived() to attempt to deliver the message to the application again. Do not free the message and topic storage when returning 0, otherwise the redelivery will fail.