[C.C++] c语言 api,c API 文档

345 0
Honkers 2025-5-20 01:17:08 来自手机 | 显示全部楼层 |阅读模式

DMS C Asynchronous API

头文件

#include "DMSAsyncApi.h"

创建客户端对象

#define ADDRESS "tcp://mqtt.dms.aodianyun.com:1883"

#define CLIENTID "Publisher0"

DMSAsync client;

//创建客户端对象,失败返回 NULL

client = DMSAsync_create(ADDRESS, CLIENTID);

设置回调函数

//成功返回 DMSASYNC_SUCCESS,失败返回 DMSASYNC_FAILURE

//第二个参数为传递给回调函数的context

DMSAsync_setCallbacks(client, client, connectionLost, messageArrived, deliveryComplete);

回调函数定义

int messageArrived(void *context, char *topicName, int topicLen, DMSAsync_message *message)

{

printf("messageArrived-->%s:%.*s\n", topicName, message->payloadlen, (char*)message->payload);

fflush(stdout);

DMSAsync_freeMessage(&message);

DMSAsync_free(topicName);

return 1;

}

void connectionLost(void *conte

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Honkers

荣誉红客

关注
  • 4013
    主题
  • 36
    粉丝
  • 0
    关注
这家伙很懒,什么都没留下!

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2025 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行