pub struct EventLoop {
pub mqtt_options: MqttOptions,
pub state: MqttState,
pub pending: VecDeque<(NoticeTx, Request)>,
pub network: Option<Network>,
pub network_options: NetworkOptions,
/* private fields */
}
Expand description
Eventloop with all the state of a connection
Fields§
§mqtt_options: MqttOptions
Options of the current mqtt connection
state: MqttState
Current state of the connection
pending: VecDeque<(NoticeTx, Request)>
Pending packets from last session
network: Option<Network>
Network connection to the broker
network_options: NetworkOptions
Implementations§
Source§impl EventLoop
impl EventLoop
Sourcepub fn new(mqtt_options: MqttOptions, cap: usize) -> EventLoop
pub fn new(mqtt_options: MqttOptions, cap: usize) -> EventLoop
New MQTT EventLoop
When connection encounters critical errors (like auth failure), user has a choice to
access and update options
, state
and requests
.
Sourcepub fn clean(&mut self)
pub fn clean(&mut self)
Last session might contain packets which aren’t acked. MQTT says these packets should be republished in the next session. Move pending messages from state to eventloop, drops the underlying network connection and clears the keepalive timeout if any.
NOTE: Use only when EventLoop is blocked on network and unable to immediately handle disconnect. Also, while this helps prevent data loss, the pending list length should be managed properly. For this reason we recommend setting
AsycClient
’s channel capacity to0
.
Sourcepub async fn poll(&mut self) -> Result<Event, ConnectionError>
pub async fn poll(&mut self) -> Result<Event, ConnectionError>
Yields Next notification or outgoing request and periodically pings the broker. Continuing to poll will reconnect to the broker if there is a disconnection. NOTE Don’t block this while iterating