参数: handle – A valid client handle from a successful call to MQTTClient_create(). context – A pointer to any application-specific context. The the <i>context</i> pointer is passed to each of the callback functions to provide access to the context information in the callback. cl – A pointer to an MQTTClient_connectionLost() callback function. You can set this to NULL if your application doesn't handle disconnections. ma – A pointer to an MQTTClient_messageArrived() callback function. This callback function must be set when you call MQTTClient_setCallbacks(), as otherwise there would be nowhere to deliver any incoming messages. dc – A pointer to an MQTTClient_deliveryComplete() callback function. You can set this to NULL if your application publishes synchronously or if you do not want to check for successful delivery. 返回: ::MQTTCLIENT_SUCCESS if the callbacks were correctly set, ::MQTTCLIENT_FAILURE if an error occurred.
时间: 2024-04-26 14:23:04 浏览: 178
Google插件JSON-handle-0.6.1.crx
这个函数的参数包括:handle——一个由MQTTClient_create()函数成功调用后返回的有效客户端句柄;context——一个指向任何应用程序特定上下文的指针。context指针将传递给每个回调函数,以便在回调函数中访问上下文信息。cl——一个指向MQTTClient_connectionLost()回调函数的指针。如果你的应用程序不处理断开连接,可以将其设置为NULL。ma——一个指向MQTTClient_messageArrived()回调函数的指针。在调用MQTTClient_setCallbacks()函数时,必须设置此回调函数,否则无法传递任何传入的消息。dc——一个指向MQTTClient_deliveryComplete()回调函数的指针。如果你的应用程序同步发布或不想检查成功发布,则可以将其设置为NULL。 返回值:如果回调函数正确设置,则返回MQTTCLIENT_SUCCESS,如果发生错误,则返回MQTTCLIENT_FAILURE。
阅读全文