class
MQTT::V5::Client
- MQTT::V5::Client
- MQTT::ClientBase
- Reference
- Object
Overview
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
Defined in:
mqtt/v5/client.crConstructors
- .new(transport : Transport, timeout : Time::Span | Nil = DEFAULT_TIMEOUT, max_packet_size : UInt32 = MQTT::DEFAULT_MAX_PACKET_SIZE)
- .new(timeout : Time::Span | Nil = DEFAULT_TIMEOUT, max_packet_size : UInt32 = MQTT::DEFAULT_MAX_PACKET_SIZE, reconnect : MQTT::Reconnect = MQTT::Reconnect.new, &factory : -> Transport)
Class Method Summary
Instance Method Summary
-
#assigned_client_id : String | Nil
The identifier the broker assigned when we sent an empty one
- #authenticator : Authenticator | Nil
- #authenticator=(authenticator : Authenticator | Nil)
- #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
- #disconnect(send_msg = true, reason : ReasonCode = ReasonCode::Success) : Nil
-
#disconnect_reason : ReasonCode | Nil
Why the broker closed the connection, when it said
-
#parse_message(io)
Handles a decoded packet.
-
#ping(timeout : Time::Span | Nil = @timeout) : Nil
Sends whatever this protocol version uses for a liveness check, and waits for the response
- #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)
- #publish_received(pub : Publish)
-
#reauthenticate(timeout : Time::Span | Nil = @timeout) : Nil
Re-authenticates an established connection, MQTT-4.12.1.
- #server_maximum_packet_size : UInt32 | Nil
- #server_maximum_qos : QoS
-
#server_receive_maximum : UInt16
What the broker told us it will accept, from the CONNACK
-
#server_reference : String | Nil
Where the broker told us to go instead, from a CONNACK or a DISCONNECT
- #server_retain_available? : Bool
- #server_shared_subscriptions_available? : Bool
- #server_subscription_identifiers_available? : Bool
- #server_topic_alias_maximum : UInt16
- #server_wildcard_available? : Bool
-
#session_expiry_interval : UInt32 | Nil
The session expiry the broker settled on, which may differ from ours
- #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)
-
#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
- #subscriptions : Hash(String, QoS)
- #unsubscribe(*topics, timeout : Time::Span | Nil = @timeout)
-
#use_topic_aliases=(use_topic_aliases : Bool)
Use topic aliases when the broker offers them.
-
#use_topic_aliases? : Bool
Use topic aliases when the broker offers them.
Instance methods inherited from class MQTT::ClientBase
closed?
closed?,
last_ping_response : Time | Nil
last_ping_response,
max_packet_size : UInt32
max_packet_size,
parse_message(io)
parse_message,
ping(timeout : Time::Span | Nil) : Nil
ping,
terminated? : Bool
terminated?,
timeout : Time::Span | Nil
timeout,
timeout=(timeout : Time::Span | Nil)
timeout=,
wait_close : Nil
wait_close
Constructor methods inherited from class MQTT::ClientBase
new(timeout : Time::Span | Nil, max_packet_size : UInt32, factory : Proc(Transport), reconnect : MQTT::Reconnect)new(transport : Transport, timeout : Time::Span | Nil = DEFAULT_TIMEOUT, max_packet_size : UInt32 = MQTT::DEFAULT_MAX_PACKET_SIZE) new
Constructor Detail
Class Method Detail
Instance Method Detail
The identifier the broker assigned when we sent an empty one
Handles a decoded packet. Implemented per protocol version
Sends whatever this protocol version uses for a liveness check, and waits for the response
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
Where the broker told us to go instead, from a CONNACK or a DISCONNECT
The session expiry the broker settled on, which may differ from ours
Full form, also used by the block version above
Use topic aliases when the broker offers them. Saves repeating a topic string on every publish; set false to always send the topic
Use topic aliases when the broker offers them. Saves repeating a topic string on every publish; set false to always send the topic