pub struct SessionManager { /* private fields */ }Expand description
Session manager for tracking all client sessions
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(max_connections: usize, metrics: Option<Arc<MqttMetrics>>) -> Self
pub fn new(max_connections: usize, metrics: Option<Arc<MqttMetrics>>) -> Self
Create a new session manager
Sourcepub async fn connect(
&self,
client_id: String,
clean_session: bool,
keep_alive: u16,
sender: ClientSender,
) -> Result<(bool, ConnackCode), ConnackCode>
pub async fn connect( &self, client_id: String, clean_session: bool, keep_alive: u16, sender: ClientSender, ) -> Result<(bool, ConnackCode), ConnackCode>
Handle a new client connection
Sourcepub async fn disconnect(&self, client_id: &str)
pub async fn disconnect(&self, client_id: &str)
Handle client disconnect
Sourcepub async fn subscribe(
&self,
client_id: &str,
subscriptions: Vec<(String, QoS)>,
) -> Option<Vec<SubackReturnCode>>
pub async fn subscribe( &self, client_id: &str, subscriptions: Vec<(String, QoS)>, ) -> Option<Vec<SubackReturnCode>>
Handle SUBSCRIBE packet
Sourcepub async fn unsubscribe(
&self,
client_id: &str,
topic_filters: Vec<String>,
) -> bool
pub async fn unsubscribe( &self, client_id: &str, topic_filters: Vec<String>, ) -> bool
Handle UNSUBSCRIBE packet
Sourcepub async fn publish(&self, publisher_id: &str, publish: &PublishPacket)
pub async fn publish(&self, publisher_id: &str, publish: &PublishPacket)
Handle PUBLISH packet - route to subscribers
Sourcepub async fn handle_puback(&self, client_id: &str, packet_id: u16)
pub async fn handle_puback(&self, client_id: &str, packet_id: u16)
Handle PUBACK from client
Sourcepub async fn handle_pubrec(&self, client_id: &str, packet_id: u16) -> bool
pub async fn handle_pubrec(&self, client_id: &str, packet_id: u16) -> bool
Handle PUBREC from client (QoS 2 step 1)
Sourcepub async fn handle_pubrel(&self, client_id: &str, packet_id: u16) -> bool
pub async fn handle_pubrel(&self, client_id: &str, packet_id: u16) -> bool
Handle PUBREL from client (QoS 2 step 2)
Sourcepub async fn handle_pubcomp(&self, client_id: &str, packet_id: u16)
pub async fn handle_pubcomp(&self, client_id: &str, packet_id: u16)
Handle PUBCOMP from client (QoS 2 step 3)
Sourcepub async fn get_retained_messages(
&self,
filter: &str,
) -> Vec<(String, PublishPacket)>
pub async fn get_retained_messages( &self, filter: &str, ) -> Vec<(String, PublishPacket)>
Get retained messages matching a topic filter
Sourcepub async fn get_sender(&self, client_id: &str) -> Option<ClientSender>
pub async fn get_sender(&self, client_id: &str) -> Option<ClientSender>
Get sender for a specific client
Sourcepub async fn get_connected_clients(&self) -> Vec<String>
pub async fn get_connected_clients(&self) -> Vec<String>
Get list of connected client IDs
Sourcepub async fn connection_count(&self) -> usize
pub async fn connection_count(&self) -> usize
Get count of active connections
Sourcepub async fn cleanup_expired_sessions(&self) -> Vec<String>
pub async fn cleanup_expired_sessions(&self) -> Vec<String>
Check and disconnect expired sessions
Sourcepub async fn assign_packet_id(&self, client_id: &str) -> Option<u16>
pub async fn assign_packet_id(&self, client_id: &str) -> Option<u16>
Assign a packet ID for outgoing QoS > 0 message
Sourcepub async fn get_client_subscriptions(
&self,
client_id: &str,
) -> Vec<(String, QoS)>
pub async fn get_client_subscriptions( &self, client_id: &str, ) -> Vec<(String, QoS)>
Get a client’s subscriptions
Sourcepub async fn start_qos2_inbound(&self, client_id: &str, packet_id: u16)
pub async fn start_qos2_inbound(&self, client_id: &str, packet_id: u16)
Start QoS 2 inbound tracking
Sourcepub async fn mark_pubrec_sent(&self, client_id: &str, packet_id: u16)
pub async fn mark_pubrec_sent(&self, client_id: &str, packet_id: u16)
Mark PUBREC sent for QoS 2 inbound
Sourcepub async fn complete_qos2_inbound(&self, client_id: &str, packet_id: u16)
pub async fn complete_qos2_inbound(&self, client_id: &str, packet_id: u16)
Complete QoS 2 inbound (PUBCOMP sent)
Auto Trait Implementations§
impl !Freeze for SessionManager
impl !RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
impl UnwindSafe for SessionManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more