I'm using mosquitto c++ wrapper to publish message/file.
In my test I can easily send messages that contain text, but how can I send a file?
My publisher method is:
bool Publisher::publish(const char* message) {
const int ret = mosquittopp::publish(NULL, topic_, strlen(message),
(uint8_t*) message);
/* custom log for mosquitto passing res and what I'm doing */
MosquittoLog::checkResult(ret, "sending message");
return (ret == MOSQ_ERR_SUCCESS);
}
I find this post where is explained how publish file with python.
Is in c++ almost the same?
If it, how can I distinguish between files and plain text on the Subscriber?
void Subscriber::on_message(const struct mosquitto_message* message) {
/* pseudode
if message is file do A
else if plainText do B
*/
}