Struct loirc::ActivityMonitor [] [src]

pub struct ActivityMonitor {
    // some fields omitted
}

This struct monitors a connection's activity.

It works in a few simple, steps. First, it monitors activity via the feed method, saving a timestamp for relevant events. If no activity is detected over the given period of time, it will send a ping request to the IRC server. If no ping reply is received, it will trigger a disconnect which may lead to reconnection depending on the reconnection settings.

The amount of time to wait, without activity, before sending a ping request, and the amount of time to wait for the ping reply can be configured via the MonitorSettings struct.

Methods

impl ActivityMonitor

fn new(handle: &Writer, settings: MonitorSettings) -> ActivityMonitor

Create a new ActivityMonitor.

The handle to a Writer allows the monitor to notify the connection of disconnects.

fn feed(&self, event: &Event)

Give an event received from the connection to the monitor.

The monitor will process it accordingly. If an Event::Closed event is received, it will shutdown all of its activities.

Trait Implementations

impl Drop for ActivityMonitor

Drop stops the background thread and clears the monitor's resources.

If you want the activity monitor to cease its activites, you can simply drop it. It will not affect the connection on which the activity monitor operates.

fn drop(&mut self)