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.
627 628 629 |
# File 'lib/mqtt/sn/packet.rb', line 627 def duration @duration end |
Instance Method Details
#encode_body ⇒ Object
633 634 635 636 637 638 639 |
# File 'lib/mqtt/sn/packet.rb', line 633 def encode_body if duration.nil? or duration == 0 '' else [duration].pack('n') end end |
#parse_body(buffer) ⇒ Object
641 642 643 644 645 646 647 |
# File 'lib/mqtt/sn/packet.rb', line 641 def parse_body(buffer) if buffer.length == 2 self.duration = buffer.unpack('n').first else self.duration = nil end end |