class

MQTT::Header

Inherits BinData / Reference / Object

Performs binary encoding and decoding of the fixed header.

NOTE:: the fixed header is byte identical in 3.1.1 and 5.0, so both protocol versions build their packets on this

Constants

AFTER_DESERIALIZE = [] of Nil

Performs binary encoding and decoding of the fixed header.

NOTE:: the fixed header is byte identical in 3.1.1 and 5.0, so both protocol versions build their packets on this

BEFORE_SERIALIZE = [] of Nil

Performs binary encoding and decoding of the fixed header.

NOTE:: the fixed header is byte identical in 3.1.1 and 5.0, so both protocol versions build their packets on this

ENDIAN = ["big"]

Performs binary encoding and decoding of the fixed header.

NOTE:: the fixed header is byte identical in 3.1.1 and 5.0, so both protocol versions build their packets on this

KLASS_NAME = [MQTT::Header]

Performs binary encoding and decoding of the fixed header.

NOTE:: the fixed header is byte identical in 3.1.1 and 5.0, so both protocol versions build their packets on this

PARTS = [{type: "bitfield", name: 0, cls: MQTT::Header, onlyif: nil, verify: nil, endian: IO::ByteFormat::BigEndian}, {type: "basic", name: variable_length1, cls: UInt8, onlyif: nil, verify: nil, value: nil, endian: nil}, {type: "basic", name: variable_length2, cls: UInt8, onlyif: -> do (variable_length1 & 128) > 0 end, verify: nil, value: nil, endian: nil}, {type: "basic", name: variable_length3, cls: UInt8, onlyif: -> do (variable_length2 & 128) > 0 end, verify: nil, value: nil, endian: nil}, {type: "basic", name: variable_length4, cls: UInt8, onlyif: -> do (variable_length3 & 128) > 0 end, verify: nil, value: nil, endian: nil}] of Nil

Performs binary encoding and decoding of the fixed header.

NOTE:: the fixed header is byte identical in 3.1.1 and 5.0, so both protocol versions build their packets on this

REMAINING = [] of Nil

Performs binary encoding and decoding of the fixed header.

NOTE:: the fixed header is byte identical in 3.1.1 and 5.0, so both protocol versions build their packets on this

UNCACHED = 4294967295_u32

invalid packet size to indicate if cached

Class methods

bit_fields

Performs binary encoding and decoding of the fixed header.

NOTE:: the fixed header is byte identical in 3.1.1 and 5.0, so both protocol versions build their packets on this

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
duplicate
Source
duplicate=(duplicate : UInt8)
duplicate=(value : Bool)
Source
fixed_header_size

Number of bytes the fixed header occupies on the wire. Avoids serialising the header just to measure it.

NOTE:: this counts continuation bits rather than deriving the size from the decoded value. A remote host can send a non-minimal encoding, and the framing has to follow what is actually on the wire

Source
id=(id : UInt8)
packet_length
Source
packet_length=(size : UInt32) : UInt32
Source
qos=(qos : UInt8)
qos=(value : MQTT::QoS)
Source
qos?
Source
retain
Source
retain=(retain : UInt8)
retain=(value : Bool)
Source
variable_length1
variable_length1=(value : UInt8) : UInt8
Source
variable_length2
variable_length2=(value : UInt8) : UInt8
Source
variable_length3
variable_length3=(value : UInt8) : UInt8
Source
variable_length4
variable_length4=(value : UInt8) : UInt8
Source