class

MQTT::ClientBase

Inherits Reference / Object

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.

Constants

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

Source
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

Source

Instance methods

closed?
Source
last_ping_response
Source
max_packet_size

Largest packet we're willing to buffer from the broker

Source
parse_message(io)

Handles a decoded packet. Implemented per protocol version

Source
ping(timeout : Time::Span | Nil) : Nil

Sends whatever this protocol version uses for a liveness check, and waits for the response

Source
terminated?
Source
timeout

Applied to any request that isn't given an explicit timeout. Set to nil to wait indefinitely

Source
timeout=(timeout : Time::Span | Nil)

Applied to any request that isn't given an explicit timeout. Set to nil to wait indefinitely

Source
wait_close

Returns once the MQTT connection has terminated

Source

Nested types