Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add MQTT v5 connection session_expiry_interval support #854

Merged
merged 5 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rumqttc/examples/async_manual_acks_v5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fn create_conn() -> (AsyncClient, EventLoop) {
let mut mqttoptions = MqttOptions::new("test-1", "localhost", 1884);
mqttoptions
.set_keep_alive(Duration::from_secs(5))
.set_session_expiry_interval(u32::MAX.into())
swanandx marked this conversation as resolved.
Show resolved Hide resolved
.set_manual_acks(true)
.set_clean_start(false);

Expand Down
21 changes: 21 additions & 0 deletions rumqttc/src/v5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,27 @@ impl MqttOptions {
self.connect_properties.clone()
}

/// set session expiry interval on connection properties
pub fn set_session_expiry_interval(&mut self, interval: Option<u32>) -> &mut Self {
if let Some(conn_props) = &mut self.connect_properties {
conn_props.session_expiry_interval = interval;
self
} else {
let mut conn_props = ConnectProperties::new();
conn_props.session_expiry_interval = interval;
self.set_connect_properties(conn_props)
}
}

/// get session expiry interval on connection properties
pub fn session_expiry_interval(&self) -> Option<u32> {
if let Some(conn_props) = &self.connect_properties {
conn_props.session_expiry_interval
} else {
None
}
}

/// set receive maximum on connection properties
pub fn set_receive_maximum(&mut self, recv_max: Option<u16>) -> &mut Self {
if let Some(conn_props) = &mut self.connect_properties {
Expand Down