MQTT 版本 5 在 paho.mqtt.golang 中发布属性?
MQTT version 5 publish properties in paho.mqtt.golang?
我正在查看 MQTT v5 差异并注意到“header”信息可以在具有用户属性的消息的 body 之外发布。 paho.mqtt.golang 对此有支持吗?查看Publish功能,只支持client.Publish(topic, qos, retain, message_bytes).
paho.mqtt.golang
only supports MQTT 3/3.1. If you want properties, which were introduced in v5, take a look at paho.golang
which is a total rewrite that supports MQTT v5 (and v5 only). Support for properties is demonstrated in the chat example:
pb := &paho.Publish{
Topic: *topic,
QoS: byte(*qos),
Payload: []byte(message),
Properties: &paho.PublishProperties{
User: map[string]string{
"chatname": *name,
},
},
}
请注意,paho.golang
is fairly stable it does not offer the same level of functionality as paho.mqtt.golang
(for example persistence; see this issue 了解更多信息)。
我正在查看 MQTT v5 差异并注意到“header”信息可以在具有用户属性的消息的 body 之外发布。 paho.mqtt.golang 对此有支持吗?查看Publish功能,只支持client.Publish(topic, qos, retain, message_bytes).
paho.mqtt.golang
only supports MQTT 3/3.1. If you want properties, which were introduced in v5, take a look at paho.golang
which is a total rewrite that supports MQTT v5 (and v5 only). Support for properties is demonstrated in the chat example:
pb := &paho.Publish{
Topic: *topic,
QoS: byte(*qos),
Payload: []byte(message),
Properties: &paho.PublishProperties{
User: map[string]string{
"chatname": *name,
},
},
}
请注意,paho.golang
is fairly stable it does not offer the same level of functionality as paho.mqtt.golang
(for example persistence; see this issue 了解更多信息)。