This library contains the wrapper code for sending messages to a Windows messaging environment (ME). For this implementation, MQTT is used as ME, implemented using Eclipse Mosquitto.
#include "cpp-msgenv-MQTT.git/IPSME_MsgEnv.h"
int main()
{
mosquitto_lib_init();
// ...
mosquitto_lib_cleanup();
return 0;
}
- include:
<path>\mosquitto\devel
- lib:
<path>\mosquitto\devel
- dependencies:
mosquitto.lib
- runtime:
PATH=($PATH);<path>\mosquitto
void handler_(const char* psz_msg, void* p_void)
{
std::cout << "Received message: " << psz_msg << std::endl;
}
RET_TYPE ret = IPSME_MsgEnv::subscribe(&handler_, NULL);
assert(ret == 0);
while (true) {
IPSME_MsgEnv::process_requests();
// ...
}
It is by design that a participant receives the messages it has published itself. If this is not desirable, each message can contain a "referer" (sic) identifier and a clause added in the ipsme_handler_
to drop those messages containing the participant's own referer id.
RET_TYPE ret = IPSME_MsgEnv::publish("...");
assert(ret == 0);
This implementation uses Eclipse Mosquitto as a dependency. A native implementation can be done later.