我在 linux 下为 mosquitto 使用 cpp 包装器。
初始化后:
this->keepalive = 60;
this->id = id;
this->port = port;
this->host = host;
this->topic = topic;
mosquittopp::log_init(MOSQ_LOG_ALL, MOSQ_LOG_STDOUT);
const int result = connect(host, port, keepalive);
如何发布我的自定义消息?
我以这种方式使用包装器定义的发布方法:
int publish(uint16_t *mid, const char *topic, uint32_t payloadlen=0, const uint8_t *payload=NULL, int qos=0, bool retain=false);
所以我可以这样调用:
publish(NULL, topic, strlen(message));
但是..我可以在哪里指定真正的“信息”?