module

LavinMQ::MQTT

Constants

EXCHANGE = "mqtt.default"
MAX_TOPIC_BYTESIZE = UInt8::MAX

Topics become routing keys and topic filters binding keys, both stored as AMQP short strings, so longer ones can't be written to a queue. MQTT itself allows topics up to 65535 bytes.

QOS0_ARGUMENTS = AMQP::Table.new({QOS_HEADER => 0_u8})
QOS1_ARGUMENTS = AMQP::Table.new({QOS_HEADER => 1_u8})
QOS_HEADER = "mqtt.qos"
RETAIN_HEADER = "mqtt.retain"
RETAIN_HEADERS = AMQP::Table.new({RETAIN_HEADER => true})
SESSION_PREFIX = "mqtt."

Class methods

qos(arguments : AMQP::Table | Nil) : UInt8

The QoS carried in binding arguments, the inverse of qos_arguments.

Any integer type is accepted: bindings made over the HTTP API or imported from a definitions file don't go through the MQTT protocol parser, so the header isn't necessarily a UInt8. The value is granted as the closest supported QoS, never higher than what we can deliver: QoS 2 as QoS 1 [MQTT-3.9.3-1], a missing, negative or non-integer value as QoS 0.

Source
qos_arguments(qos : UInt8) : AMQP::Table

The binding arguments that carry the given QoS, as one of the two shared, treat-as-read-only constants above, so no table is allocated per subscription. QoS 2 isn't supported and is granted as QoS 1, hence anything above 0 maps to QOS1_ARGUMENTS.

Source

Nested types