From 35b190ef6729b781708325ba5fc5dcc206f04fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korina=20=C5=A0imi=C4=8Devi=C4=87?= Date: Mon, 4 Dec 2023 15:31:17 +0100 Subject: [PATCH] Declaration changes meaning fix Summary: resolves T13222 Reviewers: ivica Reviewed By: ivica Subscribers: miljen, iljazovic Maniphest Tasks: T13222 Differential Revision: https://repo.mireo.local/D26828 --- README.md | 1 + include/async_mqtt5/detail/internal_types.hpp | 10 +++---- include/async_mqtt5/impl/client_service.hpp | 26 +++++++++---------- include/async_mqtt5/impl/connect_op.hpp | 12 ++++----- include/async_mqtt5/impl/disconnect_op.hpp | 4 +-- include/async_mqtt5/impl/reconnect_op.hpp | 2 +- include/async_mqtt5/property_types.hpp | 2 +- test/unit/test/session.cpp | 6 ----- 8 files changed, 29 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index f01eb95..d35d8b1 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ Async.MQTT5 is a header-only library. To use Async.MQTT5 it requires the followi Async.MQTT5 has been tested with the following compilers: - clang 14.0 (Linux) +- GCC 12 (Linux) - MSVC 14.37 - Visual Studio 2022 (Windows) Contributing diff --git a/include/async_mqtt5/detail/internal_types.hpp b/include/async_mqtt5/detail/internal_types.hpp index 799c677..da2c903 100644 --- a/include/async_mqtt5/detail/internal_types.hpp +++ b/include/async_mqtt5/detail/internal_types.hpp @@ -66,16 +66,16 @@ private: } }; -struct mqtt_context { - credentials credentials; - std::optional will; +struct mqtt_ctx { + credentials creds; + std::optional will_msg; connect_props co_props; connack_props ca_props; - session_state session_state; + session_state state; any_authenticator authenticator; }; -struct disconnect_context { +struct disconnect_ctx { disconnect_rc_e reason_code = disconnect_rc_e::normal_disconnection; disconnect_props props = {}; bool terminal = false; diff --git a/include/async_mqtt5/impl/client_service.hpp b/include/async_mqtt5/impl/client_service.hpp index 4872e6e..034ac61 100644 --- a/include/async_mqtt5/impl/client_service.hpp +++ b/include/async_mqtt5/impl/client_service.hpp @@ -25,31 +25,31 @@ requires has_tls_layer class stream_context { using tls_context_type = TlsContext; - mqtt_context _mqtt_context; + mqtt_ctx _mqtt_context; tls_context_type _tls_context; public: explicit stream_context(TlsContext tls_context) : _tls_context(std::move(tls_context)) {} - mqtt_context& mqtt_context() { + auto& mqtt_context() { return _mqtt_context; } - TlsContext& tls_context() { + auto& tls_context() { return _tls_context; } auto& session_state() { - return _mqtt_context.session_state; + return _mqtt_context.state; } const auto& session_state() const { - return _mqtt_context.session_state; + return _mqtt_context.state; } void will(will will) { - _mqtt_context.will = std::move(will); + _mqtt_context.will_msg = std::move(will); } template @@ -61,7 +61,7 @@ public: std::string client_id, std::string username = "", std::string password = "" ) { - _mqtt_context.credentials = { + _mqtt_context.creds = { std::move(client_id), std::move(username), std::move(password) }; @@ -78,24 +78,24 @@ public: template requires (!has_tls_layer) class stream_context { - mqtt_context _mqtt_context; + mqtt_ctx _mqtt_context; public: explicit stream_context(std::monostate) {} - mqtt_context& mqtt_context() { + auto& mqtt_context() { return _mqtt_context; } auto& session_state() { - return _mqtt_context.session_state; + return _mqtt_context.state; } const auto& session_state() const { - return _mqtt_context.session_state; + return _mqtt_context.state; } void will(will will) { - _mqtt_context.will = std::move(will); + _mqtt_context.will_msg = std::move(will); } template @@ -107,7 +107,7 @@ public: std::string client_id, std::string username = "", std::string password = "" ) { - _mqtt_context.credentials = { + _mqtt_context.creds = { std::move(client_id), std::move(username), std::move(password) }; diff --git a/include/async_mqtt5/impl/connect_op.hpp b/include/async_mqtt5/impl/connect_op.hpp index 042ce9d..68efb36 100644 --- a/include/async_mqtt5/impl/connect_op.hpp +++ b/include/async_mqtt5/impl/connect_op.hpp @@ -39,7 +39,7 @@ class connect_op { struct on_complete_auth {}; Stream& _stream; - mqtt_context& _ctx; + mqtt_ctx& _ctx; using handler_type = asio::any_completion_handler; handler_type _handler; @@ -52,7 +52,7 @@ class connect_op { public: template connect_op( - Stream& stream, Handler&& handler, mqtt_context& ctx + Stream& stream, Handler&& handler, mqtt_ctx& ctx ) : _stream(stream), _ctx(ctx), _handler(std::forward(handler)) @@ -190,9 +190,9 @@ public: auto packet = control_packet::of( no_pid, get_allocator(), encoders::encode_connect, - _ctx.credentials.client_id, - _ctx.credentials.username, _ctx.credentials.password, - 10u, false, _ctx.co_props, _ctx.will + _ctx.creds.client_id, + _ctx.creds.username, _ctx.creds.password, + 10u, false, _ctx.co_props, _ctx.will_msg ); const auto& wire_data = packet.wire_data(); @@ -283,7 +283,7 @@ public: const auto& [session_present, reason_code, ca_props] = *rv; _ctx.ca_props = ca_props; - _ctx.session_state.session_present(session_present); + _ctx.state.session_present(session_present); // TODO: session_present logic // Unexpected result handling: diff --git a/include/async_mqtt5/impl/disconnect_op.hpp b/include/async_mqtt5/impl/disconnect_op.hpp index 3dcf5fe..9ffbc7d 100644 --- a/include/async_mqtt5/impl/disconnect_op.hpp +++ b/include/async_mqtt5/impl/disconnect_op.hpp @@ -122,7 +122,7 @@ decltype(auto) async_disconnect( using Signature = void (error_code); auto initiation = []( - auto handler, disconnect_context ctx, + auto handler, disconnect_ctx ctx, const std::shared_ptr& svc_ptr ) { disconnect_op { @@ -132,7 +132,7 @@ decltype(auto) async_disconnect( return asio::async_initiate( initiation, token, - disconnect_context { reason_code, props, terminal }, + disconnect_ctx { reason_code, props, terminal }, svc_ptr ); } diff --git a/include/async_mqtt5/impl/reconnect_op.hpp b/include/async_mqtt5/impl/reconnect_op.hpp index f105cea..7f9ab49 100644 --- a/include/async_mqtt5/impl/reconnect_op.hpp +++ b/include/async_mqtt5/impl/reconnect_op.hpp @@ -126,7 +126,7 @@ public: auto init_connect = []( auto handler, typename Owner::stream_type& stream, - mqtt_context& context, const epoints& eps, authority_path ap + mqtt_ctx& context, const epoints& eps, authority_path ap ) { connect_op { stream, std::move(handler), context } .perform(eps, std::move(ap)); diff --git a/include/async_mqtt5/property_types.hpp b/include/async_mqtt5/property_types.hpp index a349be9..b6fd9ed 100644 --- a/include/async_mqtt5/property_types.hpp +++ b/include/async_mqtt5/property_types.hpp @@ -91,7 +91,7 @@ class properties { template struct property { - using key = std::integral_constant; + using key = std::integral_constant; constexpr static std::string_view name = name_v

; value_type_t

value; }; diff --git a/test/unit/test/session.cpp b/test/unit/test/session.cpp index 89e5cdc..461bcbd 100644 --- a/test/unit/test/session.cpp +++ b/test/unit/test/session.cpp @@ -1,16 +1,10 @@ #include -#include -#include -#include - #include #include using namespace async_mqtt5; -constexpr auto use_nothrow_awaitable = asio::as_tuple(asio::use_awaitable); - BOOST_AUTO_TEST_SUITE(session/*, *boost::unit_test::disabled()*/) BOOST_AUTO_TEST_CASE(session_state_session_present) {