pub struct KeepAliveManager {
pub ping_interval: Duration,
/* private fields */
}Expand description
Keep-alive manager to maintain active connections and detect dead peers
Fields§
§ping_interval: DurationInterval for sending ping messages
Implementations§
Source§impl KeepAliveManager
impl KeepAliveManager
Sourcepub fn with_settings(ping_interval: Duration, dead_timeout: Duration) -> Self
pub fn with_settings(ping_interval: Duration, dead_timeout: Duration) -> Self
Create a new keep-alive manager with custom settings
Sourcepub fn update_send(&mut self)
pub fn update_send(&mut self)
Update last send time
Sourcepub fn update_recv(&mut self)
pub fn update_recv(&mut self)
Update last receive time
Sourcepub fn should_ping(&self) -> bool
pub fn should_ping(&self) -> bool
Check if we need to send a ping to keep the connection alive
Sourcepub fn ping_interval(&self) -> Duration
pub fn ping_interval(&self) -> Duration
Get the ping interval duration
Sourcepub fn is_connection_dead(&self) -> bool
pub fn is_connection_dead(&self) -> bool
Check if the connection is considered dead (no messages received)
Sourcepub fn time_since_last_recv(&self) -> Duration
pub fn time_since_last_recv(&self) -> Duration
Get time since last received message
Sourcepub fn build_ping_message() -> Message
pub fn build_ping_message() -> Message
Build a ping message for keep-alive
Sourcepub fn process_message(&mut self, msg: &Message) -> bool
pub fn process_message(&mut self, msg: &Message) -> bool
Process an incoming message, update received timestamp if it’s not a pong Returns true if the message was a pong response to our ping
Trait Implementations§
Source§impl Debug for KeepAliveManager
impl Debug for KeepAliveManager
Auto Trait Implementations§
impl Freeze for KeepAliveManager
impl RefUnwindSafe for KeepAliveManager
impl Send for KeepAliveManager
impl Sync for KeepAliveManager
impl Unpin for KeepAliveManager
impl UnwindSafe for KeepAliveManager
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