class
MQTT::V5::Publish
- MQTT::V5::Publish
- MQTT::Header
- BinData
- Reference
- Object
Overview
MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload
Defined in:
mqtt/v5/publish.crConstant Summary
-
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 Method Summary
-
.bit_fields
MQTT-3.3.
Instance Method Summary
-
#__format__ : IO::ByteFormat
A
grouporbit_fieldcaptures the endianness at its declaration point, so declaringendianafter one would silently leave it system-endian. - #add_subscription_identifier(value : UInt32) : Nil
- #add_user_property(key : String, value : String) : Nil
- #calculate_length : UInt32
- #content_type : String | Nil
- #content_type=(value : String | Nil)
- #correlation_data : Bytes | Nil
- #correlation_data=(value : Bytes | Nil)
- #message_expiry_interval : UInt32 | Nil
- #message_expiry_interval=(value : UInt32 | Nil)
- #message_id : UInt16
- #message_id=(message_id : UInt16)
-
#payload : Bytes
NOTE : the arithmetic is signed on purpose.
-
#payload=(payload : Bytes)
NOTE : the arithmetic is signed on purpose.
- #payload=(message)
-
#payload_format_indicator : UInt8 | Nil
0 for arbitrary bytes, 1 for UTF-8.
- #payload_format_indicator=(value : UInt8 | Nil)
- #properties : Properties
- #properties=(properties : Properties)
-
#response_topic : String | Nil
The request/response pattern, MQTT-3.3.2.3.5
- #response_topic=(value : String | Nil)
-
#subscription_identifiers : Array(UInt32)
Which subscriptions caused the broker to send us this message.
- #topic : String
- #topic=(topic : String)
-
#topic_alias : UInt16 | Nil
Replaces the topic string for the rest of the connection.
- #topic_alias=(value : UInt16 | Nil)
- #topic_size : UInt16
- #topic_size=(topic_size : UInt16)
- #user_properties : Array(Tuple(String, String))
- #utf8_payload? : Bool
- #validate! : self
Instance methods inherited from class MQTT::Header
__format__ : IO::ByteFormat
__format__,
duplicate : Bool
duplicate,
duplicate=(duplicate : UInt8)duplicate=(value : Bool) duplicate=, fixed_header_size : Int32 fixed_header_size, id : MQTT::RequestType id, id=(id : UInt8)
id=(value : MQTT::RequestType) id=, packet_length : UInt32 packet_length, packet_length=(size : UInt32) : UInt32 packet_length=, qos : MQTT::QoS qos, qos=(qos : UInt8)
qos=(value : MQTT::QoS) qos=, qos? qos?, retain : Bool retain, retain=(retain : UInt8)
retain=(value : Bool) retain=, variable_length1 : UInt8 variable_length1, variable_length1=(value : UInt8) : UInt8 variable_length1=, variable_length2 : UInt8 variable_length2, variable_length2=(value : UInt8) : UInt8 variable_length2=, variable_length3 : UInt8 variable_length3, variable_length3=(value : UInt8) : UInt8 variable_length3=, variable_length4 : UInt8 variable_length4, variable_length4=(value : UInt8) : UInt8 variable_length4=
Class methods inherited from class MQTT::Header
bit_fields
bit_fields
Class Method Detail
MQTT-3.3. Same as 3.1.1 with a property section between the packet identifier and the payload
Instance Method Detail
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.
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
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
Which subscriptions caused the broker to send us this message. Repeatable, because one message can match several subscriptions
Replaces the topic string for the rest of the connection. Zero is not a valid alias, MQTT-3.3.2.3.4