class
MQTT::V3::Publish
- MQTT::V3::Publish
- MQTT::Header
- BinData
- Reference
- Object
Defined in:
mqtt/v3/publish.crConstant Summary
-
AFTER_DESERIALIZE =
[] of Nil -
BEFORE_SERIALIZE =
[] of Nil -
ENDIAN =
["big"] -
KLASS_NAME =
[MQTT::V3::Publish] -
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: "bytes", name: payload, cls: Slice(UInt8), onlyif: nil, verify: nil, length: -> do overhead = topic.bytesize + 2 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 a #{topic.bytesize} byte topic")) end len end, value: nil}] of Nil -
REMAINING =
[] of Nil
Class Method Summary
Instance Method Summary
-
#__format__ : IO::ByteFormat
A
grouporbit_fieldcaptures the endianness at its declaration point, so declaringendianafter one would silently leave it system-endian. - #calculate_length : UInt32
- #message_id : UInt16
- #message_id=(message_id : UInt16)
-
#payload : Bytes
The data to be published
-
#payload=(payload : Bytes)
The data to be published
- #payload=(message)
- #topic : String
- #topic=(topic : String)
- #topic_size : UInt16
- #topic_size=(topic_size : UInt16)
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
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.
The data to be published
NOTE : the arithmetic here has to be signed. A malformed packet can
advertise a remaining-length smaller than the fields that precede the
payload, which underflows UInt32 into a ~4GB allocation
The data to be published
NOTE : the arithmetic here has to be signed. A malformed packet can
advertise a remaining-length smaller than the fields that precede the
payload, which underflows UInt32 into a ~4GB allocation