forked from boostorg/mqtt5
Fix build
Summary: related to T15996 Reviewers: iljazovic Reviewed By: iljazovic Subscribers: miljen Differential Revision: https://repo.mireo.local/D33388
This commit is contained in:
@ -79,15 +79,15 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
// If you want to use the Client without logging, initialise it with the following line instead.
|
// If you want to use the Client without logging, initialise it with the following line instead.
|
||||||
//boost::mqtt5::mqtt_client<
|
//boost::mqtt5::mqtt_client<
|
||||||
// boost::asio::ssl::stream<boost::asio::ip::tcp::socket>,
|
// boost::asio::ssl::stream<boost::asio::ip::tcp::socket>,
|
||||||
// boost::asio::ssl::context
|
// boost::asio::ssl::context
|
||||||
//> client(ioc, std::move(context));
|
//> client(ioc, std::move(context));
|
||||||
|
|
||||||
client.brokers(cfg.brokers, cfg.port) // Broker that we want to connect to.
|
client.brokers(cfg.brokers, cfg.port) // Broker that we want to connect to.
|
||||||
.credentials(cfg.client_id) // Set the Client Identifier. (optional)
|
.credentials(cfg.client_id) // Set the Client Identifier. (optional)
|
||||||
.async_run(boost::asio::detached); // Start the Client.
|
.async_run(boost::asio::detached); // Start the Client.
|
||||||
|
|
||||||
client.async_publish<boost/mqtt5::qos_e::at_most_once>(
|
client.async_publish<boost::mqtt5::qos_e::at_most_once>(
|
||||||
"async-mqtt5/test", "Hello world!",
|
"async-mqtt5/test", "Hello world!",
|
||||||
boost::mqtt5::retain_e::no, boost::mqtt5::publish_props{},
|
boost::mqtt5::retain_e::no, boost::mqtt5::publish_props{},
|
||||||
[&client](boost::mqtt5::error_code ec) {
|
[&client](boost::mqtt5::error_code ec) {
|
||||||
|
@ -80,8 +80,8 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
// If you want to use the Client without logging, initialise it with the following line instead.
|
// If you want to use the Client without logging, initialise it with the following line instead.
|
||||||
//boost::mqtt5::mqtt_client<
|
//boost::mqtt5::mqtt_client<
|
||||||
// boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>,
|
// boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>,
|
||||||
// boost::asio::ssl::context
|
// boost::asio::ssl::context
|
||||||
//> client(ioc, std::move(context));
|
//> client(ioc, std::move(context));
|
||||||
|
|
||||||
client.brokers(cfg.brokers, cfg.port) // Broker that we want to connect to.
|
client.brokers(cfg.brokers, cfg.port) // Broker that we want to connect to.
|
||||||
|
@ -67,7 +67,7 @@ boost::asio::awaitable<void> publish_sensor_readings(
|
|||||||
auto&& [ec, rc, props] = co_await client.async_publish<boost::mqtt5::qos_e::at_least_once>(
|
auto&& [ec, rc, props] = co_await client.async_publish<boost::mqtt5::qos_e::at_least_once>(
|
||||||
"async-mqtt5/test" /* topic */, reading /* payload */,
|
"async-mqtt5/test" /* topic */, reading /* payload */,
|
||||||
boost::mqtt5::retain_e::no, boost::mqtt5::publish_props {}, use_nothrow_awaitable
|
boost::mqtt5::retain_e::no, boost::mqtt5::publish_props {}, use_nothrow_awaitable
|
||||||
);
|
);
|
||||||
// An error can occur as a result of:
|
// An error can occur as a result of:
|
||||||
// a) wrong publish parameters
|
// a) wrong publish parameters
|
||||||
// b) mqtt_client::cancel is called while the Client is publishing the message
|
// b) mqtt_client::cancel is called while the Client is publishing the message
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <variant> // std::monostate
|
||||||
|
|
||||||
namespace boost::mqtt5::detail {
|
namespace boost::mqtt5::detail {
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <variant> // std::monostate
|
||||||
|
|
||||||
namespace boost::mqtt5::detail {
|
namespace boost::mqtt5::detail {
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ enum class retain_handling_e : std::uint8_t {
|
|||||||
* \brief Represents the \__SUBSCRIBE_OPTIONS\__ associated with each Subscription.
|
* \brief Represents the \__SUBSCRIBE_OPTIONS\__ associated with each Subscription.
|
||||||
*/
|
*/
|
||||||
struct subscribe_options {
|
struct subscribe_options {
|
||||||
/** \brief Maximum \__QOS\__ level at which the Server can send Application Messages to the Client.
|
/** \brief Maximum \__QOS\__ level at which the Server can send Application Messages to the Client. */
|
||||||
qos_e max_qos = qos_e::exactly_once;
|
qos_e max_qos = qos_e::exactly_once;
|
||||||
|
|
||||||
/** \brief Option determining if Application Messages will be
|
/** \brief Option determining if Application Messages will be
|
||||||
|
@ -47,19 +47,19 @@ namespace test {
|
|||||||
// the following code needs to compile
|
// the following code needs to compile
|
||||||
|
|
||||||
template <
|
template <
|
||||||
typename StreamType,
|
typename StreamType,
|
||||||
typename TlsContextType = std::monostate,
|
typename TlsContextType = std::monostate,
|
||||||
typename Logger = noop_logger
|
typename Logger = noop_logger
|
||||||
>
|
>
|
||||||
asio::awaitable<void> test_default_completion_tokens_impl(
|
asio::awaitable<void> test_default_completion_tokens_impl(
|
||||||
TlsContextType tls_context = {}, Logger logger = {}
|
TlsContextType tls_context = {}, Logger logger = {}
|
||||||
) {
|
) {
|
||||||
asio::io_context ioc;
|
asio::io_context ioc;
|
||||||
|
|
||||||
using client_type = asio::use_awaitable_t<>::as_default_on_t<
|
using client_type = asio::use_awaitable_t<>::as_default_on_t<
|
||||||
mqtt_client<StreamType, TlsContextType, Logger>
|
mqtt_client<StreamType, TlsContextType, Logger>
|
||||||
>;
|
>;
|
||||||
client_type c(ioc, std::move(tls_context), std::move(logger));
|
client_type c(ioc, std::move(tls_context), std::move(logger));
|
||||||
|
|
||||||
co_await c.async_run();
|
co_await c.async_run();
|
||||||
|
|
||||||
@ -98,14 +98,14 @@ asio::awaitable<void> test_default_completion_tokens() {
|
|||||||
boost::beast::websocket::stream<asio::ip::tcp::socket>
|
boost::beast::websocket::stream<asio::ip::tcp::socket>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
co_await test_default_completion_tokens_impl<
|
co_await test_default_completion_tokens_impl<
|
||||||
boost::beast::websocket::stream<asio::ssl::stream<asio::ip::tcp::socket>>,
|
boost::beast::websocket::stream<asio::ssl::stream<asio::ip::tcp::socket>>,
|
||||||
asio::ssl::context,
|
asio::ssl::context,
|
||||||
logger
|
logger
|
||||||
>(
|
>(
|
||||||
asio::ssl::context(asio::ssl::context::tls_client),
|
asio::ssl::context(asio::ssl::context::tls_client),
|
||||||
logger(log_level::debug)
|
logger(log_level::debug)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace test
|
} // end namespace test
|
||||||
|
Reference in New Issue
Block a user