MqttConnectionKeepAlive class

Implements keep alive functionality on the Mqtt Connection, ensuring that the connection remains active according to the keep alive seconds setting. This class implements the keep alive by sending an MqttPingRequest to the broker if a message has not been sent or received within the keep alive period. Optionally a disconnect on no response property can be set to force disconnect the client if the broker does not respond to a ping request for a specified period of time.

Constructors

MqttConnectionKeepAlive(IMqttConnectionHandler connectionHandler, EventBus? eventBus, int keepAliveSeconds, [int disconnectOnNoResponsePeriod = 0])
Initializes a new instance of the MqttConnectionKeepAlive class.

Properties

averageCycleLatency int
Average latency(time between sending a ping and receiving a pong) in ms of all the ping/pong cycles in a connection period. Reset on disconnect.
getter/setter pair
disconnectOnNoResponsePeriod int
The period of time to wait if the broker does not respond to a ping request, in milliseconds. If this time period is exceeded the client is forcibly disconnected. The default is 0, which disables this functionality.
getter/setter pair
disconnectTimer Timer?
Timer that manages the disconnect on no ping response period.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
keepAlivePeriod int
The keep alive period in milliseconds
getter/setter pair
lastCycleLatency int
Latency(time between sending a ping and receiving a pong) in ms of the last ping/pong cycle. Reset on disconnect.
getter/setter pair
pingCallback PingCallback?
Ping request sent callback.
getter/setter pair
pingTimer Timer?
The timer that manages the ping callbacks.
getter/setter pair
pongCallback PongCallback?
Ping response received callback.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

messageSent(MqttMessage? msg) bool
Handles the MessageSent event of the connectionHandler control.
noMessageSent() → void
Handle when send message throws error
noPingResponseReceived() → void
Handle the disconnect timer timeout
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pingRequestReceived(MqttMessage? pingMsg) bool
A ping request has been received from the message broker. The effect of calling this method on the keep alive handler is the transmission of a ping response message to the message broker on the current connection.
pingRequired() bool
Pings the message broker if there has been no activity for the specified amount of idle time.
pingResponseReceived(MqttMessage? pingMsg) bool
Processed ping response messages received from a message broker.
stop() → void
Stop the keep alive process
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited