Class: MQTT::SN::Packet::Disconnect
- Inherits:
-
MQTT::SN::Packet
- Object
- MQTT::SN::Packet
- MQTT::SN::Packet::Disconnect
- Defined in:
- lib/mqtt/sn/packet.rb
Constant Summary collapse
- DEFAULTS =
{ :duration => nil }
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
Attributes inherited from MQTT::SN::Packet
#clean_session, #duplicate, #qos, #request_will, #retain, #topic_id_type
Instance Method Summary collapse
Methods inherited from MQTT::SN::Packet
#initialize, parse, #to_s, #type_id, #update_attributes
Constructor Details
This class inherits a constructor from MQTT::SN::Packet
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
594 595 596 |
# File 'lib/mqtt/sn/packet.rb', line 594 def duration @duration end |
Instance Method Details
#encode_body ⇒ Object
600 601 602 603 604 605 606 |
# File 'lib/mqtt/sn/packet.rb', line 600 def encode_body if duration.nil? || duration.zero? '' else [duration].pack('n') end end |
#parse_body(buffer) ⇒ Object
608 609 610 |
# File 'lib/mqtt/sn/packet.rb', line 608 def parse_body(buffer) self.duration = buffer.length == 2 ? buffer.unpack('n').first : nil end |