class MQTT::Header

Overview

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

Direct Known Subclasses

Defined in:

mqtt/header.cr

Constant Summary

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 Method Summary

Instance Method Summary

Class Method Detail

def self.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


[View source]

Instance Method Detail

def __format__ : IO::ByteFormat #

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.


[View source]
def duplicate : Bool #

[View source]
def duplicate=(duplicate : UInt8) #

def duplicate=(value : Bool) #

[View source]
def fixed_header_size : Int32 #

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


[View source]
def id : MQTT::RequestType #

[View source]
def id=(id : UInt8) #

def id=(value : MQTT::RequestType) #

[View source]
def packet_length : UInt32 #

[View source]
def packet_length=(size : UInt32) : UInt32 #

[View source]
def qos : MQTT::QoS #

[View source]
def qos=(qos : UInt8) #

def qos=(value : MQTT::QoS) #

[View source]
def qos? #

[View source]
def retain : Bool #

[View source]
def retain=(retain : UInt8) #

def retain=(value : Bool) #

[View source]
def variable_length1 : UInt8 #

def variable_length1=(value : UInt8) : UInt8 #

[View source]
def variable_length2 : UInt8 #

def variable_length2=(value : UInt8) : UInt8 #

[View source]
def variable_length3 : UInt8 #

def variable_length3=(value : UInt8) : UInt8 #

[View source]
def variable_length4 : UInt8 #

def variable_length4=(value : UInt8) : UInt8 #

[View source]