add a notification in receive channel when session resets

Summary: resolves T13152

Reviewers: ivica

Reviewed By: ivica

Subscribers: miljen, iljazovic

Maniphest Tasks: T13152

Differential Revision: https://repo.mireo.local/D26679
This commit is contained in:
Korina Šimičević
2023-11-23 15:36:06 +01:00
parent 5034734fc4
commit b4f4cd0047
12 changed files with 189 additions and 29 deletions

View File

@@ -28,7 +28,7 @@ class stream_context<StreamType, TlsContext> {
mqtt_context _mqtt_context;
tls_context_type _tls_context;
public:
stream_context(TlsContext tls_context) :
explicit stream_context(TlsContext tls_context) :
_tls_context(std::move(tls_context))
{}
@@ -72,7 +72,7 @@ requires (!has_tls_layer<StreamType>)
class stream_context<StreamType, std::monostate> {
mqtt_context _mqtt_context;
public:
stream_context(std::monostate) {}
explicit stream_context(std::monostate) {}
mqtt_context& mqtt_context() {
return _mqtt_context;
@@ -289,6 +289,15 @@ public:
);
}
void update_session_state() {
auto& session_state = _stream_context.mqtt_context().session_state;
if (!session_state.session_present()) {
channel_store_error(client::error::session_expired);
_replies.clear_pending_pubrels();
session_state.session_present(true);
}
}
bool channel_store(decoders::publish_message message) {
auto& [topic, packet_id, flags, props, payload] = message;
return _rec_channel.try_send(
@@ -297,6 +306,10 @@ public:
);
}
bool channel_store_error(error_code ec) {
return _rec_channel.try_send(ec, std::string {}, std::string {}, publish_props {});
}
template <typename CompletionToken>
decltype(auto) async_channel_receive(CompletionToken&& token) {
// sig = void (error_code, std::string, std::string, publish_props)