class

MQTT::V5::Client

Inherits MQTT::ClientBase / Reference / Object

An MQTT 5.0 client.

The transport lifecycle, request pipeline, keep alive and reconnection all live in MQTT::ClientBase. What follows is the 5.0 specific half.

The substantive difference from 3.1.1 is that acknowledgements now carry a reason: a PUBACK can say the publish was rejected, and a SUBACK can reject individual filters. Those are raised rather than resolved

Constructors

new(transport : Transport, timeout : Time::Span | Nil = DEFAULT_TIMEOUT, max_packet_size : UInt32 = MQTT::DEFAULT_MAX_PACKET_SIZE)
Source
new(timeout : Time::Span | Nil = DEFAULT_TIMEOUT, max_packet_size : UInt32 = MQTT::DEFAULT_MAX_PACKET_SIZE, reconnect : MQTT::Reconnect = MQTT::Reconnect.new, &factory : -> Transport)
Source

Class methods

topic_matches(filter : String, topic : String)
Source

Instance methods

assigned_client_id

The identifier the broker assigned when we sent an empty one

Source
authenticator
Source
authenticator=(authenticator : Authenticator | Nil)
Source
connect(username : String | Nil = nil, password : String | Nil = nil, keep_alive : Int32 = 60, client_id : String = MQTT.generate_client_id, clean_start : Bool = true, session_expiry_interval : UInt32 | Nil = nil, receive_maximum : UInt16 | Nil = nil, will_flag : Bool = false, will_qos : Int32 | QoS = 0, will_retain : Bool = false, will_topic : String | Nil = nil, will_payload : String | Bytes | Nil = nil, will_delay_interval : UInt32 | Nil = nil, timeout : Time::Span | Nil = @timeout, keep_alive_active : Bool = true) : Connack
Source
disconnect(send_msg = true, reason : ReasonCode = ReasonCode::Success) : Nil
Source
disconnect_reason

Why the broker closed the connection, when it said

Source
parse_message(io)

Handles a decoded packet. Implemented per protocol version

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

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

Source
publish(topic : String, payload = "", retain : Bool = false, qos : QoS = QoS::FireAndForget, content_type : String | Nil = nil, response_topic : String | Nil = nil, correlation_data : Bytes | Nil = nil, message_expiry_interval : UInt32 | Nil = nil, payload_format_indicator : UInt8 | Nil = nil, user_properties : Enumerable(Tuple(String, String)) | Nil = nil, timeout : Time::Span | Nil = @timeout)
Source
publish_received(pub : Publish)
Source
reauthenticate(timeout : Time::Span | Nil = @timeout) : Nil

Re-authenticates an established connection, MQTT-4.12.1. The broker answers with further challenges and finally an AUTH carrying Success, or drops the connection

Source
server_maximum_packet_size
Source
server_maximum_qos
Source
server_receive_maximum

What the broker told us it will accept, from the CONNACK

Source
server_reference

Where the broker told us to go instead, from a CONNACK or a DISCONNECT

Source
server_retain_available?
Source
server_shared_subscriptions_available?
Source
server_subscription_identifiers_available?
Source
server_topic_alias_maximum
Source
server_wildcard_available?
Source
session_expiry_interval

The session expiry the broker settled on, which may differ from ours

Source
subscribe(*topics, qos : QoS = QoS::FireAndForget, no_local : Bool = false, retain_as_published : Bool = false, retain_handling : RetainHandling = RetainHandling::SendAlways, identifier : UInt32 | Nil = nil, timeout : Time::Span | Nil = @timeout, &callback : String, Bytes, Bool -> Nil)
Source
subscribe(filters : Enumerable(String), callback : Callback, qos : QoS = QoS::FireAndForget, no_local : Bool = false, retain_as_published : Bool = false, retain_handling : RetainHandling = RetainHandling::SendAlways, identifier : UInt32 | Nil = nil, timeout : Time::Span | Nil = @timeout)

Full form, also used by the block version above

Source
subscriptions
Source
unsubscribe(*topics, timeout : Time::Span | Nil = @timeout)
Source
use_topic_aliases=(use_topic_aliases : Bool)

Use topic aliases when the broker offers them. Saves repeating a topic string on every publish; set false to always send the topic

Source
use_topic_aliases?

Use topic aliases when the broker offers them. Saves repeating a topic string on every publish; set false to always send the topic

Source

Nested types