class

MQTT::V5::Publish

Inherits MQTT::Header / BinData / Reference / Object

MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload

Constants

AFTER_DESERIALIZE = [] of Nil

MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload

ALLOWED_PROPERTIES = [PropertyId::PayloadFormatIndicator, PropertyId::MessageExpiryInterval, PropertyId::TopicAlias, PropertyId::ResponseTopic, PropertyId::CorrelationData, PropertyId::UserProperty, PropertyId::SubscriptionIdentifier, PropertyId::ContentType]
BEFORE_SERIALIZE = [] of Nil

MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload

ENDIAN = ["big"]

MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload

KLASS_NAME = [MQTT::V5::Publish]

MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload

PARTS = [{type: "basic", name: topic_size, cls: UInt16, onlyif: nil, verify: nil, value: -> do topic.bytesize end, endian: nil}, {type: "string", name: topic, cls: String, onlyif: nil, verify: nil, length: -> do topic_size end, value: nil, encoding: nil}, {type: "basic", name: message_id, cls: UInt16, onlyif: -> do qos? end, verify: nil, value: nil, endian: nil}, {type: "basic", name: properties, cls: MQTT::V5::Properties, onlyif: nil, verify: nil, value: nil}, {type: "bytes", name: payload, cls: Slice(UInt8), onlyif: nil, verify: nil, length: -> do overhead = (topic.bytesize + 2) + properties.total_size if qos? overhead = overhead + 2 end len = packet_length.to_i64 - overhead if len < 0 raise(MQTT::ProtocolError.new("publish packet length #{packet_length} is too small for its topic and properties")) end len end, value: nil}] of Nil

MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload

REMAINING = [] of Nil

MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload

Class methods

bit_fields

MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload

Source

Instance methods

__format__

A group or bit_field captures the endianness at its declaration point, so declaring endian after one would silently leave it system-endian. Fail loudly.

Source
add_subscription_identifier(value : UInt32) : Nil
Source
add_user_property(key : String, value : String) : Nil
Source
calculate_length
Source
content_type
Source
content_type=(value : String | Nil)
Source
correlation_data
Source
correlation_data=(value : Bytes | Nil)
Source
message_expiry_interval
Source
message_expiry_interval=(value : UInt32 | Nil)
Source
message_id
message_id=(message_id : UInt16)
payload

NOTE:: the arithmetic is signed on purpose. A malformed packet can advertise a remaining length smaller than the fields preceding the payload, which underflows UInt32 into a ~4GB allocation

payload=(payload : Bytes)

NOTE:: the arithmetic is signed on purpose. A malformed packet can advertise a remaining length smaller than the fields preceding the payload, which underflows UInt32 into a ~4GB allocation

payload=(message)
Source
payload_format_indicator

0 for arbitrary bytes, 1 for UTF-8. MQTT-3.3.2.3.2

Source
payload_format_indicator=(value : UInt8 | Nil)
Source
properties
properties=(properties : Properties)
response_topic

The request/response pattern, MQTT-3.3.2.3.5

Source
response_topic=(value : String | Nil)
Source
subscription_identifiers

Which subscriptions caused the broker to send us this message. Repeatable, because one message can match several subscriptions

Source
topic
topic=(topic : String)
topic_alias

Replaces the topic string for the rest of the connection. Zero is not a valid alias, MQTT-3.3.2.3.4

Source
topic_alias=(value : UInt16 | Nil)
Source
topic_size
topic_size=(topic_size : UInt16)
user_properties
Source
utf8_payload?
Source
validate!
Source