Class: EventMachine::MQTTSN::Packet::Publish

Inherits:
EventMachine::MQTTSN::Packet show all
Defined in:
lib/em/mqtt-sn/packet.rb

Constant Summary collapse

DEFAULTS =
{
  :id => 0x00,
  :duplicate => false,
  :qos => 0,
  :retain => false,
  :topic_id_type => :normal
}

Instance Attribute Summary collapse

Attributes inherited from EventMachine::MQTTSN::Packet

#clean_session, #duplicate, #qos, #request_will, #retain, #topic_id_type

Instance Method Summary collapse

Methods inherited from EventMachine::MQTTSN::Packet

#initialize, parse, #to_s, #type_id, #update_attributes

Constructor Details

This class inherits a constructor from EventMachine::MQTTSN::Packet

Instance Attribute Details

#dataObject

Returns the value of attribute data.



239
240
241
# File 'lib/em/mqtt-sn/packet.rb', line 239

def data
  @data
end

#idObject

Returns the value of attribute id.



238
239
240
# File 'lib/em/mqtt-sn/packet.rb', line 238

def id
  @id
end

#topic_idObject

Returns the value of attribute topic_id.



237
238
239
# File 'lib/em/mqtt-sn/packet.rb', line 237

def topic_id
  @topic_id
end

Instance Method Details

#encode_bodyObject



249
250
251
# File 'lib/em/mqtt-sn/packet.rb', line 249

def encode_body
  [encode_flags, encode_topic_id, id, data].pack('Cnna*')
end

#parse_body(buffer) ⇒ Object



253
254
255
256
257
# File 'lib/em/mqtt-sn/packet.rb', line 253

def parse_body(buffer)
  flags, topic_id, self.id, self.data = buffer.unpack('Cnna*')
  parse_flags(flags)
  parse_topic_id(topic_id)
end