我正在使用 mosquitto 向订阅者发布一些消息。
对于订户,我使用:
mosquitto_sub -h 主机 -t "new_topic" -q 0
相反,为了发布,我开发了一个使用 mosquittopp 包装器的程序,但不相关。
我使用这种方法发送消息:
int MyClass::publish(const char* message) {
return mosquittopp::publish(NULL, topic_, strlen(message),
(uint8_t*) message, qos_);
}
....
MyClass publisher;
string s = base64_decode("LAAAtQ8AIXRpwoVyeMKodMK2wpPDscKBYcKDw6jCg8KAYWDDhjVCMQ==");
publisher.publish(s.c_str());
如果我打印 s,我会得到:
,�!tirx¨t¶ñaèa`Æ5B1
我认为还可以。
但订阅者似乎只收到第一个字符,实际上只打印:
,
有任何想法吗?
更新
这是我使用的版本(1.3.1)的一个错误,从版本 1.3.4 修复。