如何在节点azure iot sdk中添加消息属性

问题描述 投票:0回答:1

使用天蓝色的C sdk,可以使用Map_AddOrUpdate(propMap, "propKey", propText)向邮件信封添加属性。有类似的东西吗?我正在使用

const Protocol = require('azure-iot-device-mqtt').Mqtt;
const Client = require('azure-iot-device').Client;
const Message = require('azure-iot-device').Message;

client = Client.fromConnectionString(deviceConnectionString, Protocol);
// misc code
 return new Promise( (resolve,reject) => {
    client.sendEvent(message,(err,res) => {
      if ( err ) {
        logger.error(TAG,'Failed to send message: ', err.toString())
        reject(err)
      }
      if (res) logger.info(TAG,'Send status: ' + res.constructor.name);
      resolve(res)
    })
  })

我无法在客户端界面中找到允许我设置信封属性的任何内容。

node.js azure azure-iot-hub azure-node-sdk
1个回答
0
投票

您可以执行:message.properties.add('yourProp', 'val')。您可能会发现this sample有用。

© www.soinside.com 2019 - 2024. All rights reserved.