三方库推荐MQTT
使应用程序能够连接到MQTT代理以发布消息、订阅主题和接收发布的消息。
下载安装
ohpm install @ohos/mqtt
使用说明
import { MqttAsync } from '@ohos/mqtt';
目录结构
|----ohos_mqtt
| |---- entry # 示例代码文件夹
| |---- ohos_Mqtt # ohos_Mqtt库文件夹
| |---- cpp # c/c++和napi代码
| |---- mqtt_napi # mqtt的napi逻辑代码
| |---- CMakeLists.txt # 构建脚本
| |---- boundscheck # 子模块third_party_bounds_checking_function
| |---- paho.mqtt.c # 子模块paho.mqtt.c
| |---- ets # 接口声明
| |---- index.ets # 对外接口
参考
https://gitee.com/openharmony-tpc/ohos_mqtt