Class: MQTT::SN::Packet::Disconnect
- Defined in:
- lib/mqtt/sn/packet.rb
Constant Summary collapse
- DEFAULTS =
{ duration: nil }.freeze
Constants inherited from Packet
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
Attributes inherited from Packet
#body_length, #flags, #id, #version
Instance Method Summary collapse
Methods inherited from Packet
create_from_header, #dup, #initialize, #inspect, #message_id, #message_id=, parse, parse_header, read, read_byte, #to_s, #type_id, #type_name, #update_attributes, #validate_flags
Constructor Details
This class inherits a constructor from MQTT::Packet
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
588 589 590 |
# File 'lib/mqtt/sn/packet.rb', line 588 def duration @duration end |
Instance Method Details
#encode_body ⇒ Object
594 595 596 597 598 599 600 |
# File 'lib/mqtt/sn/packet.rb', line 594 def encode_body if duration.nil? || duration.zero? "" else [duration].pack("n") end end |
#parse_body(buffer) ⇒ Object
602 603 604 |
# File 'lib/mqtt/sn/packet.rb', line 602 def parse_body(buffer) self.duration = (buffer.length == 2) ? buffer.unpack1("n") : nil end |