Class: MiniMqtt::ConnackPacket
- Inherits:
-
Packet
- Object
- Packet
- MiniMqtt::ConnackPacket
show all
- Defined in:
- lib/mini_mqtt/connack_packet.rb
Constant Summary
collapse
- ERRORS =
{ 1 => "unacceptable protocol version",
2 => "identifier rejected",
3 => "server unavailable",
4 => "bad username or password",
5 => "not authorized" }
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Packet
#decode, #encode, #flags, get_packet_class, packet_type_id
Methods included from BinHelper
#flag_byte, #mqtt_utf8_encode, #read_mqtt_encoded_string, #read_ushort, #uchar, #ushort
Instance Attribute Details
#return_code ⇒ Object
Returns the value of attribute return_code.
3
4
5
|
# File 'lib/mini_mqtt/connack_packet.rb', line 3
def return_code
@return_code
end
|
Instance Method Details
#accepted? ⇒ Boolean
22
23
24
|
# File 'lib/mini_mqtt/connack_packet.rb', line 22
def accepted?
@return_code == 0
end
|
#error_message ⇒ Object
26
27
28
|
# File 'lib/mini_mqtt/connack_packet.rb', line 26
def error_message
ERRORS[@return_code]
end
|
13
14
15
16
|
# File 'lib/mini_mqtt/connack_packet.rb', line 13
def
@session_present = @stream.readbyte & 0x01
@return_code = @stream.readbyte
end
|
#session_present? ⇒ Boolean
18
19
20
|
# File 'lib/mini_mqtt/connack_packet.rb', line 18
def session_present?
@session_present == 1
end
|