class

MQTT::V3::Publish

Inherits MQTT::Header / BinData / Reference / Object

Constants

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 methods

bit_fields
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
calculate_length
Source
message_id
message_id=(message_id : UInt16)
payload

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

payload=(payload : Bytes)

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

payload=(message)
Source
topic
topic=(topic : String)
topic_size
topic_size=(topic_size : UInt16)