Class: MQTT::SN::Packet::Willtopicupd

Inherits:
MQTT::SN::Packet show all
Defined in:
lib/mqtt/sn/packet.rb

Constant Summary collapse

DEFAULTS =
{
  :qos => 0,
  :retain => false,
  :topic_name => nil
}

Instance Attribute Summary collapse

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

#topic_nameObject

Returns the value of attribute topic_name


651
652
653
# File 'lib/mqtt/sn/packet.rb', line 651

def topic_name
  @topic_name
end

Instance Method Details

#encode_bodyObject


659
660
661
662
663
664
665
# File 'lib/mqtt/sn/packet.rb', line 659

def encode_body
  if topic_name.nil? or topic_name.empty?
    ''
  else
    [encode_flags, topic_name].pack('Ca*')
  end
end

#parse_body(buffer) ⇒ Object


667
668
669
670
671
672
673
674
# File 'lib/mqtt/sn/packet.rb', line 667

def parse_body(buffer)
  if buffer.length > 1
    flags, self.topic_name = buffer.unpack('Ca*')
    parse_flags(flags)
  else
    self.topic_name = nil
  end
end