Class: MQTT::SN::Packet::Willtopic
- Inherits:
-
MQTT::SN::Packet
- Object
- MQTT::SN::Packet
- MQTT::SN::Packet::Willtopic
- Defined in:
- lib/mqtt/sn/packet.rb
Constant Summary collapse
- DEFAULTS =
{ :qos => 0, :retain => false, :topic_name => nil }
Instance Attribute Summary collapse
-
#topic_name ⇒ Object
Returns the value of attribute topic_name.
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_name ⇒ Object
Returns the value of attribute topic_name.
302 303 304 |
# File 'lib/mqtt/sn/packet.rb', line 302 def topic_name @topic_name end |
Instance Method Details
#encode_body ⇒ Object
310 311 312 313 314 315 316 |
# File 'lib/mqtt/sn/packet.rb', line 310 def encode_body if topic_name.nil? || topic_name.empty? '' else [encode_flags, topic_name].pack('Ca*') end end |
#parse_body(buffer) ⇒ Object
318 319 320 321 322 323 324 325 326 |
# File 'lib/mqtt/sn/packet.rb', line 318 def parse_body(buffer) if buffer.length > 1 flags, self.topic_name = buffer.unpack('Ca*') else flags, _ignore = buffer.unpack('C') self.topic_name = nil end parse_flags(flags) end |