サードパーティのライブラリは 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