mirror of
https://github.com/boostorg/mqtt5.git
synced 2025-10-04 04:40:55 +02:00
Do not store ec=session_expired if the client never subscribed
Summary: related to T13152 Reviewers: ivica Reviewed By: ivica Subscribers: miljen, iljazovic Differential Revision: https://repo.mireo.local/D26803
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <boost/asio/experimental/basic_concurrent_channel.hpp>
|
||||
|
||||
#include <async_mqtt5/detail/internal_types.hpp>
|
||||
#include <async_mqtt5/detail/channel_traits.hpp>
|
||||
#include <async_mqtt5/detail/internal_types.hpp>
|
||||
|
||||
#include <async_mqtt5/impl/assemble_op.hpp>
|
||||
#include <async_mqtt5/impl/async_sender.hpp>
|
||||
@@ -40,6 +40,14 @@ public:
|
||||
return _tls_context;
|
||||
}
|
||||
|
||||
auto& session_state() {
|
||||
return _mqtt_context.session_state;
|
||||
}
|
||||
|
||||
const auto& session_state() const {
|
||||
return _mqtt_context.session_state;
|
||||
}
|
||||
|
||||
void will(will will) {
|
||||
_mqtt_context.will = std::move(will);
|
||||
}
|
||||
@@ -78,6 +86,14 @@ public:
|
||||
return _mqtt_context;
|
||||
}
|
||||
|
||||
auto& session_state() {
|
||||
return _mqtt_context.session_state;
|
||||
}
|
||||
|
||||
const auto& session_state() const {
|
||||
return _mqtt_context.session_state;
|
||||
}
|
||||
|
||||
void will(will will) {
|
||||
_mqtt_context.will = std::move(will);
|
||||
}
|
||||
@@ -289,12 +305,25 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
bool subscriptions_present() const {
|
||||
return _stream_context.session_state().subscriptions_present();
|
||||
}
|
||||
|
||||
void subscriptions_present(bool present) {
|
||||
_stream_context.session_state().subscriptions_present(present);
|
||||
}
|
||||
|
||||
void update_session_state() {
|
||||
auto& session_state = _stream_context.mqtt_context().session_state;
|
||||
auto& session_state = _stream_context.session_state();
|
||||
|
||||
if (!session_state.session_present()) {
|
||||
channel_store_error(client::error::session_expired);
|
||||
_replies.clear_pending_pubrels();
|
||||
session_state.session_present(true);
|
||||
|
||||
if (session_state.subscriptions_present()) {
|
||||
channel_store_error(client::error::session_expired);
|
||||
session_state.subscriptions_present(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#ifndef ASYNC_MQTT5_SUBSCRIBE_OP_HPP
|
||||
#define ASYNC_MQTT5_SUBSCRIBE_OP_HPP
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/asio/detached.hpp>
|
||||
|
||||
#include <async_mqtt5/error.hpp>
|
||||
@@ -173,6 +175,15 @@ private:
|
||||
error_code ec, uint16_t packet_id,
|
||||
std::vector<reason_code> reason_codes, suback_props props
|
||||
) {
|
||||
if (!_svc_ptr->subscriptions_present()) {
|
||||
bool has_success_rc = std::any_of(
|
||||
reason_codes.cbegin(), reason_codes.cend(),
|
||||
[](const reason_code& rc) { return !rc; }
|
||||
);
|
||||
if (has_success_rc)
|
||||
_svc_ptr->subscriptions_present(true);
|
||||
}
|
||||
|
||||
_svc_ptr->free_pid(packet_id);
|
||||
_handler.complete(ec, std::move(reason_codes), std::move(props));
|
||||
}
|
||||
|
Reference in New Issue
Block a user