mirror of
https://github.com/boostorg/mqtt5.git
synced 2025-08-02 14:04:36 +02:00
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
This commit is contained in:
@@ -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:
|
Async.MQTT5 has been tested with the following compilers:
|
||||||
- clang 14.0 (Linux)
|
- clang 14.0 (Linux)
|
||||||
|
- GCC 12 (Linux)
|
||||||
- MSVC 14.37 - Visual Studio 2022 (Windows)
|
- MSVC 14.37 - Visual Studio 2022 (Windows)
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
|
@@ -66,16 +66,16 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mqtt_context {
|
struct mqtt_ctx {
|
||||||
credentials credentials;
|
credentials creds;
|
||||||
std::optional<will> will;
|
std::optional<will> will_msg;
|
||||||
connect_props co_props;
|
connect_props co_props;
|
||||||
connack_props ca_props;
|
connack_props ca_props;
|
||||||
session_state session_state;
|
session_state state;
|
||||||
any_authenticator authenticator;
|
any_authenticator authenticator;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct disconnect_context {
|
struct disconnect_ctx {
|
||||||
disconnect_rc_e reason_code = disconnect_rc_e::normal_disconnection;
|
disconnect_rc_e reason_code = disconnect_rc_e::normal_disconnection;
|
||||||
disconnect_props props = {};
|
disconnect_props props = {};
|
||||||
bool terminal = false;
|
bool terminal = false;
|
||||||
|
@@ -25,31 +25,31 @@ requires has_tls_layer<StreamType>
|
|||||||
class stream_context<StreamType, TlsContext> {
|
class stream_context<StreamType, TlsContext> {
|
||||||
using tls_context_type = TlsContext;
|
using tls_context_type = TlsContext;
|
||||||
|
|
||||||
mqtt_context _mqtt_context;
|
mqtt_ctx _mqtt_context;
|
||||||
tls_context_type _tls_context;
|
tls_context_type _tls_context;
|
||||||
public:
|
public:
|
||||||
explicit stream_context(TlsContext tls_context) :
|
explicit stream_context(TlsContext tls_context) :
|
||||||
_tls_context(std::move(tls_context))
|
_tls_context(std::move(tls_context))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
mqtt_context& mqtt_context() {
|
auto& mqtt_context() {
|
||||||
return _mqtt_context;
|
return _mqtt_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
TlsContext& tls_context() {
|
auto& tls_context() {
|
||||||
return _tls_context;
|
return _tls_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& session_state() {
|
auto& session_state() {
|
||||||
return _mqtt_context.session_state;
|
return _mqtt_context.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& session_state() const {
|
const auto& session_state() const {
|
||||||
return _mqtt_context.session_state;
|
return _mqtt_context.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void will(will will) {
|
void will(will will) {
|
||||||
_mqtt_context.will = std::move(will);
|
_mqtt_context.will_msg = std::move(will);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Prop>
|
template <typename Prop>
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
std::string client_id,
|
std::string client_id,
|
||||||
std::string username = "", std::string password = ""
|
std::string username = "", std::string password = ""
|
||||||
) {
|
) {
|
||||||
_mqtt_context.credentials = {
|
_mqtt_context.creds = {
|
||||||
std::move(client_id),
|
std::move(client_id),
|
||||||
std::move(username), std::move(password)
|
std::move(username), std::move(password)
|
||||||
};
|
};
|
||||||
@@ -78,24 +78,24 @@ public:
|
|||||||
template <typename StreamType>
|
template <typename StreamType>
|
||||||
requires (!has_tls_layer<StreamType>)
|
requires (!has_tls_layer<StreamType>)
|
||||||
class stream_context<StreamType, std::monostate> {
|
class stream_context<StreamType, std::monostate> {
|
||||||
mqtt_context _mqtt_context;
|
mqtt_ctx _mqtt_context;
|
||||||
public:
|
public:
|
||||||
explicit stream_context(std::monostate) {}
|
explicit stream_context(std::monostate) {}
|
||||||
|
|
||||||
mqtt_context& mqtt_context() {
|
auto& mqtt_context() {
|
||||||
return _mqtt_context;
|
return _mqtt_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& session_state() {
|
auto& session_state() {
|
||||||
return _mqtt_context.session_state;
|
return _mqtt_context.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& session_state() const {
|
const auto& session_state() const {
|
||||||
return _mqtt_context.session_state;
|
return _mqtt_context.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void will(will will) {
|
void will(will will) {
|
||||||
_mqtt_context.will = std::move(will);
|
_mqtt_context.will_msg = std::move(will);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Prop>
|
template <typename Prop>
|
||||||
@@ -107,7 +107,7 @@ public:
|
|||||||
std::string client_id,
|
std::string client_id,
|
||||||
std::string username = "", std::string password = ""
|
std::string username = "", std::string password = ""
|
||||||
) {
|
) {
|
||||||
_mqtt_context.credentials = {
|
_mqtt_context.creds = {
|
||||||
std::move(client_id),
|
std::move(client_id),
|
||||||
std::move(username), std::move(password)
|
std::move(username), std::move(password)
|
||||||
};
|
};
|
||||||
|
@@ -39,7 +39,7 @@ class connect_op {
|
|||||||
struct on_complete_auth {};
|
struct on_complete_auth {};
|
||||||
|
|
||||||
Stream& _stream;
|
Stream& _stream;
|
||||||
mqtt_context& _ctx;
|
mqtt_ctx& _ctx;
|
||||||
|
|
||||||
using handler_type = asio::any_completion_handler<void (error_code)>;
|
using handler_type = asio::any_completion_handler<void (error_code)>;
|
||||||
handler_type _handler;
|
handler_type _handler;
|
||||||
@@ -52,7 +52,7 @@ class connect_op {
|
|||||||
public:
|
public:
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
connect_op(
|
connect_op(
|
||||||
Stream& stream, Handler&& handler, mqtt_context& ctx
|
Stream& stream, Handler&& handler, mqtt_ctx& ctx
|
||||||
) :
|
) :
|
||||||
_stream(stream), _ctx(ctx),
|
_stream(stream), _ctx(ctx),
|
||||||
_handler(std::forward<Handler>(handler))
|
_handler(std::forward<Handler>(handler))
|
||||||
@@ -190,9 +190,9 @@ public:
|
|||||||
auto packet = control_packet<allocator_type>::of(
|
auto packet = control_packet<allocator_type>::of(
|
||||||
no_pid, get_allocator(),
|
no_pid, get_allocator(),
|
||||||
encoders::encode_connect,
|
encoders::encode_connect,
|
||||||
_ctx.credentials.client_id,
|
_ctx.creds.client_id,
|
||||||
_ctx.credentials.username, _ctx.credentials.password,
|
_ctx.creds.username, _ctx.creds.password,
|
||||||
10u, false, _ctx.co_props, _ctx.will
|
10u, false, _ctx.co_props, _ctx.will_msg
|
||||||
);
|
);
|
||||||
|
|
||||||
const auto& wire_data = packet.wire_data();
|
const auto& wire_data = packet.wire_data();
|
||||||
@@ -283,7 +283,7 @@ public:
|
|||||||
const auto& [session_present, reason_code, ca_props] = *rv;
|
const auto& [session_present, reason_code, ca_props] = *rv;
|
||||||
|
|
||||||
_ctx.ca_props = ca_props;
|
_ctx.ca_props = ca_props;
|
||||||
_ctx.session_state.session_present(session_present);
|
_ctx.state.session_present(session_present);
|
||||||
|
|
||||||
// TODO: session_present logic
|
// TODO: session_present logic
|
||||||
// Unexpected result handling:
|
// Unexpected result handling:
|
||||||
|
@@ -122,7 +122,7 @@ decltype(auto) async_disconnect(
|
|||||||
using Signature = void (error_code);
|
using Signature = void (error_code);
|
||||||
|
|
||||||
auto initiation = [](
|
auto initiation = [](
|
||||||
auto handler, disconnect_context ctx,
|
auto handler, disconnect_ctx ctx,
|
||||||
const std::shared_ptr<ClientService>& svc_ptr
|
const std::shared_ptr<ClientService>& svc_ptr
|
||||||
) {
|
) {
|
||||||
disconnect_op {
|
disconnect_op {
|
||||||
@@ -132,7 +132,7 @@ decltype(auto) async_disconnect(
|
|||||||
|
|
||||||
return asio::async_initiate<CompletionToken, Signature>(
|
return asio::async_initiate<CompletionToken, Signature>(
|
||||||
initiation, token,
|
initiation, token,
|
||||||
disconnect_context { reason_code, props, terminal },
|
disconnect_ctx { reason_code, props, terminal },
|
||||||
svc_ptr
|
svc_ptr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -126,7 +126,7 @@ public:
|
|||||||
|
|
||||||
auto init_connect = [](
|
auto init_connect = [](
|
||||||
auto handler, typename Owner::stream_type& stream,
|
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 }
|
connect_op { stream, std::move(handler), context }
|
||||||
.perform(eps, std::move(ap));
|
.perform(eps, std::move(ap));
|
||||||
|
@@ -91,7 +91,7 @@ class properties {
|
|||||||
|
|
||||||
template <property_type p>
|
template <property_type p>
|
||||||
struct property {
|
struct property {
|
||||||
using key = std::integral_constant<uint8_t, p>;
|
using key = std::integral_constant<property_type, p>;
|
||||||
constexpr static std::string_view name = name_v<p>;
|
constexpr static std::string_view name = name_v<p>;
|
||||||
value_type_t<p> value;
|
value_type_t<p> value;
|
||||||
};
|
};
|
||||||
|
@@ -1,16 +1,10 @@
|
|||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include <boost/asio/as_tuple.hpp>
|
|
||||||
#include <boost/asio/co_spawn.hpp>
|
|
||||||
#include <boost/asio/use_awaitable.hpp>
|
|
||||||
|
|
||||||
#include <async_mqtt5.hpp>
|
#include <async_mqtt5.hpp>
|
||||||
#include <test_common/test_service.hpp>
|
#include <test_common/test_service.hpp>
|
||||||
|
|
||||||
using namespace async_mqtt5;
|
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_SUITE(session/*, *boost::unit_test::disabled()*/)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(session_state_session_present) {
|
BOOST_AUTO_TEST_CASE(session_state_session_present) {
|
||||||
|
Reference in New Issue
Block a user