Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Message Arrived in Paho C Async Lib Callback

Hi Frank,

when I wrote the library, it seemed to make sense to enforce the setting of the message arrived callback, to make sure any incoming messages were handled.    There are some servers where a message can be sent to the client unsolicited, without a subscription.  This isn't standard MQTT behaviour of course, although I'm not sure that the spec actually forbids it.

I'm not strongly attached to my decision to return an error if you don't set message arrived when calling setCallbacks, so I would be happy to change it.

Ian

On 09/01/15 17:43, Frank Pagliughi wrote:
Hello Ian, and all,

In the latest Paho C Async library, the publish example, MQTTAsync_publish.c, sets the callbacks as so (~line 126):
MQTTAsync_setCallbacks(client, NULL, connlost, NULL, NULL);
As makes sense with a publish-only client, it sets the 4th parameter for a "message arrived" callback to NULL.

The implementation of the MQTTAsync_setCallbacks function, however, rejects the NULL value for message arrived (ma) parameter, in MQTTAsync.c (~line 1719):
if (m == NULL || ma == NULL || m->c->connect_state != 0)
    rc = MQTTASYNC_FAILURE;
else
   ...
Which of these should be the correct behavior?  I'm guessing that the library should accept a NULL value for the callback (?).

Thanks,
Frank


Back to the top