README.md
MQTT-CPP
Modern, asynchronous and fast C++ client for paho-mqtt ( paho-c ).
Features:
- Simple and clean A-synchronous API. ( Connect, publish, subscribe ).
- Thread-safe. Use multiple topics in multiple threads..
- Callbacks can be lambdas, class methods, bind expressions, or any [std::function]
- Fully autonomous reconnecting
Dependencies
The only dependency is to libpaho-mqtt3a.so. Changes are there is a version for your platform ( Debian, Fedora, CentOS ). Just check your package manager for the correct package-name.
Tutorial
- Clone this repository :
git clone http://gitlab.osdev.nl/open_source/mqtt-cpp.git
- Change to the repo and run the submodules script :
$ cd mqtt-cpp $ scripts/setup_submodules -i
This will add the cmake directory and versioning. - Create a build directory and start the build.
$ mkdir build $ cd build $ cmake ../ $ gmake
And you're all set. In build/bin there are two examples, test_mqtt_pu and test_mqtt_sub. Have a broker running, like mosquitto or flashmq capable of accepting anonymous connections. Start the "sub" part and couple of moments later the "pub" part. If all went well, you should see two screens in sync running.
- Change to the repo and run the submodules script :
Open terminal 1
$ bin/test_mqtt_sub
Open terminal 2
$ bin/test_mqtt_pub
Screen 2 is sending, Screen 1 is receiving.