summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcel Müller <neikos@neikos.email>2024-04-04 16:14:54 +0200
committerMarcel Müller <neikos@neikos.email>2024-04-04 16:16:32 +0200
commit2d31fe958190bf7f9cf97a3bd2b9484c5408ee58 (patch)
tree92386fd714943be107f0e00c8bb4c0f09bec8b40 /src
parent9342e9eec4697c73e9984fdd065ad9780be992d8 (diff)
Add KeepAlive value to ConnectState
Signed-off-by: Marcel Müller <neikos@neikos.email>
Diffstat (limited to 'src')
-rw-r--r--src/client/connect.rs9
-rw-r--r--src/client/state.rs1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/client/connect.rs b/src/client/connect.rs
index 46bcf71..74864c4 100644
--- a/src/client/connect.rs
+++ b/src/client/connect.rs
@@ -225,6 +225,15 @@ impl MqttClient {
retain_available: connack.properties.retain_available().map(|ra| ra.0),
maximum_packet_size: connack.properties.maximum_packet_size().map(|mps| mps.0),
topic_alias_maximum: connack.properties.topic_alias_maximum().map(|tam| tam.0),
+ keep_alive: connack
+ .properties
+ .server_keep_alive()
+ .map(|ska| {
+ std::num::NonZeroU16::try_from(ska.0)
+ .map(KeepAlive::Seconds)
+ .unwrap_or(KeepAlive::Disabled)
+ })
+ .unwrap_or(connector.keep_alive),
conn_write,
conn_read_recv,
next_packet_identifier: std::num::NonZeroU16::MIN,
diff --git a/src/client/state.rs b/src/client/state.rs
index d3df10c..0c707d3 100644
--- a/src/client/state.rs
+++ b/src/client/state.rs
@@ -62,6 +62,7 @@ pub(super) struct ConnectState {
>,
pub(super) next_packet_identifier: std::num::NonZeroU16,
+ pub(crate) keep_alive: KeepAlive,
}
pub(super) struct SessionState {