Add function to set keep alive/ping interval

Summary:
related to T13566
- mqtt_client has a new keep_alive(seconds) function
- keep_alive(0) disables ping
- if keep_alive() is not called, the client assumes keep_alive=10
- the client respects server_keep_alive if sent by the broker

Reviewers: ivica

Reviewed By: ivica

Subscribers: miljen, iljazovic

Differential Revision: https://repo.mireo.local/D27557
This commit is contained in:
Korina Šimičević committed 2024-02-01 08:29:22 +01:00
1 parent d6c4884d53
commit 33c8eea890
21 files changed
+361 -100

No files matched your search

+7 -7
View File
@@ -70,19 +70,19 @@ BOOST_AUTO_TEST_CASE(omit_props) {
// packets
auto connect = encoders::encode_connect(
"", std::nullopt, std::nullopt, 10, false, {}, std::nullopt
"", std::nullopt, std::nullopt, 60, false, {}, std::nullopt
);
auto connack = encoders::encode_connack(
false, reason_codes::success.value(), co_props
);
disconnect_props props;
props[prop::user_property].push_back(std::string(50, 'a'));
props[prop::reason_string] = std::string(50, 'a');
auto disconnect = encoders::encode_disconnect(
reason_codes::normal_disconnection.value(), props
);
auto disconnect_no_props = encoders::encode_disconnect(
reason_codes::normal_disconnection.value(), disconnect_props{}
reason_codes::normal_disconnection.value(), disconnect_props {}
);
test::msg_exchange broker_side;
@@ -107,18 +107,18 @@ BOOST_AUTO_TEST_CASE(omit_props) {
.async_run(asio::detached);
asio::steady_timer timer(c.get_executor());
timer.expires_after(std::chrono::milliseconds(50));
timer.async_wait([&](auto) {
timer.expires_after(50ms);
timer.async_wait([&](error_code) {
c.async_disconnect(
disconnect_rc_e::normal_disconnection, props,
[&handlers_called](error_code ec) {
[&](error_code ec) {
handlers_called++;
BOOST_CHECK(!ec);
}
);
});
ioc.run_for(std::chrono::seconds(2));
ioc.run_for(2s);
BOOST_CHECK_EQUAL(handlers_called, expected_handlers_called);
BOOST_CHECK(broker.received_all_expected());
}