Add a build with CMake example to README and Introduction page

Summary: related to T13767

Reviewers: ivica

Reviewed By: ivica

Subscribers: miljen, iljazovic

Differential Revision: https://repo.mireo.local/D29243
This commit is contained in:
Korina Šimičević
2024-05-03 11:27:11 +02:00
parent 9b7f852342
commit 27c4ca1535
4 changed files with 45 additions and 10 deletions

View File

@@ -14,12 +14,12 @@ int main() {
async_mqtt5::mqtt_client<boost::asio::ip::tcp::socket> client(ioc);
// 1883 is the default TCP MQTT port.
client.brokers("<your-mqtt-broker>", 1883)
client.brokers("broker.hivemq.com", 1883)
.async_run(boost::asio::detached);
client.async_publish<async_mqtt5::qos_e::at_most_once>(
"<topic>", "Hello world!",
async_mqtt5::retain_e::no, async_mqtt5::publish_props {},
"async-mqtt5/test", "Hello world!",
async_mqtt5::retain_e::yes, async_mqtt5::publish_props {},
[&client](async_mqtt5::error_code ec) {
std::cout << ec.message() << std::endl;
client.async_disconnect(boost::asio::detached);