abstract class
MQTT::ClientBase
- MQTT::ClientBase
- Reference
- Object
Overview
The version agnostic half of an MQTT client: transport lifecycle, framing, the request pipeline, packet identifier allocation, the registry of responses we're waiting on, keep alive and reconnection.
Everything that depends on the wire format of a particular protocol version — building packets, parsing them, and what an acknowledgement means — is left to the subclass.
Direct Known Subclasses
Defined in:
mqtt/client_base.crConstant Summary
-
DEFAULT_TIMEOUT =
30.seconds -
How long to wait for a broker response before giving up
Constructors
-
.new(timeout : Time::Span | Nil, max_packet_size : UInt32, factory : Proc(Transport), reconnect : MQTT::Reconnect)
Drives the client over transports produced by factory, re-establishing the connection whenever it drops
-
.new(transport : Transport, timeout : Time::Span | Nil = DEFAULT_TIMEOUT, max_packet_size : UInt32 = MQTT::DEFAULT_MAX_PACKET_SIZE)
Drives the client over a single transport, with no reconnection
Instance Method Summary
-
#closed? : Bool
True until the broker has accepted the connection, not only while the socket is down.
- #last_ping_response : Time | Nil
-
#max_packet_size : UInt32
Largest packet we're willing to buffer from the broker
-
#on_reconnect(&on_reconnect : Bool -> Nil) : Nil
Called once a dropped connection has been re-established, with whether the broker resumed the session.
-
#parse_message(io)
Handles a decoded packet.
-
#ping(timeout : Time::Span | Nil) : Nil
Sends whatever this protocol version uses for a liveness check, and waits for the response
- #terminated? : Bool
-
#timeout : Time::Span | Nil
Applied to any request that isn't given an explicit timeout.
-
#timeout=(timeout : Time::Span | Nil)
Applied to any request that isn't given an explicit timeout.
-
#wait_close : Nil
Returns once the MQTT connection has terminated
Constructor Detail
Drives the client over transports produced by factory, re-establishing the connection whenever it drops
Drives the client over a single transport, with no reconnection
Instance Method Detail
True until the broker has accepted the connection, not only while the socket is down. Something sent before the CONNACK is processed by the broker before it has decided to accept us, and is a protocol error to a broker that is still taking an old session over
Called once a dropped connection has been re-established, with whether the broker resumed the session. Whatever the broker lost while we were away can be published again from here. Runs in its own fiber
Sends whatever this protocol version uses for a liveness check, and waits for the response
Applied to any request that isn't given an explicit timeout.
Set to nil to wait indefinitely
Applied to any request that isn't given an explicit timeout.
Set to nil to wait indefinitely