class MqttCrystal::Packet::Connect

Defined in:

mqtt_crystal/packet.cr

Constant Summary

CFLAG_CLEAN_SESSION = 2_u8
CFLAG_PASSWORD = 64_u8
CFLAG_USERNAME = 128_u8
CFLAG_WILL = 4_u8
CFLAG_WILL_RETAIN = 32_u8
PROTOCOL = "MQTT"

Constructors

Instance Method Summary

Instance methods inherited from class MqttCrystal::Packet

_extract_string!(buffer : Array(UInt8), index : Int32 = 0) : String _extract_string!, body_length : UInt64 body_length, body_length=(body_length : UInt64) body_length=, bytes : Bytes bytes, check_remaining_length(bytes : Array(UInt8)) : NamedTuple(pos: UInt8, body_length: UInt64) check_remaining_length, concatenate(*args) : Bytes concatenate, decode_short(buffer : Array(UInt8), index : Int32) : UInt16 decode_short, encode_body : Bytes encode_body, encode_header : UInt8 encode_header, encode_short(n : UInt16) : Bytes encode_short, encode_string(str : String) : Bytes
encode_string(strings : Array(String)) : Bytes
encode_string
, flags : Array(Bool) flags, flags=(flags : Array(Bool)) flags=, parse_body(buffer : Array(UInt8)) parse_body, slice_it(a : Array(UInt8)) : Bytes slice_it, type_id : Int32 type_id, validate_flags validate_flags

Constructor methods inherited from class MqttCrystal::Packet

new(flags : Array(Bool) = [false, false, false, false], body_length : UInt64 = 0_u64) new

Class methods inherited from class MqttCrystal::Packet

create_from_header(byte : UInt8) create_from_header, parse(bytes : Array(UInt8)) : Packet | Nil parse, slice_it(a : String) : Bytes
slice_it(a : Array(UInt8)) : Bytes
slice_it

Constructor Detail

def self.new(client_id : String = UUID.random.to_s, username : String | Nil = nil, password : String | Nil = nil, protocol_level : UInt8 = 4_u8, keep_alive : UInt16 = 15_u16, clean_session : Bool = true, will_retain : Bool = false, will_topic : String | Nil = nil, will_qos : UInt8 = 0_u8, will_message : String | Nil = nil, flags : Array(Bool) = [false, false, false, false], body_length : UInt64 = 0_u64) #

[View source]

Instance Method Detail

def clean_session : Bool #

[View source]
def clean_session=(clean_session : Bool) #

[View source]
def client_id : String #

[View source]
def client_id=(client_id : String) #

[View source]
def encode_body : Bytes #

[View source]
def keep_alive : UInt16 #

[View source]
def keep_alive=(keep_alive : UInt16) #

[View source]
def parse_body(buffer : Array(UInt8)) #

byte[2..5] = 'MQTT' byte[6] = Protocol requires 4 for MQTTv3.1.1 byte[7] = cflags 7 - User Name Flag - is there a username 0x80 6 - Password Flag - is there a password 0x40 5 - Will Retain 0x20 - Sould the will be retained 4 - Will QoS 0x10 - 0b10 (qos2),0b01 (qos1), 0b00 (qos0) 3 - Will QoS 0x08 2 - Will Flag 0x04 - Should there be a will message published 1 - Clean Session 0x02 0 - RESERVED (always 0) 0x00 byte[8,9] = Keepalive (seconds) from ehre on 2 byte length N bytes payload, in order: Client Identifier, Will Topic, Will Message, User Name, Password


[View source]
def password : String? #

[View source]
def password=(password : Nil | String) #

[View source]
def protocol_level : UInt8 #

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

[View source]
def username : String? #

[View source]
def username=(username : Nil | String) #

[View source]
def will_message : String? #

[View source]
def will_message=(will_message : Nil | String) #

[View source]
def will_qos : UInt8 #

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

[View source]
def will_retain : Bool #

[View source]
def will_retain=(will_retain : Bool) #

[View source]
def will_topic : String? #

[View source]
def will_topic=(will_topic : Nil | String) #

[View source]