Class: PahoMqtt::Packet::Suback
- Inherits:
-
PahoMqtt::Packet
- Object
- PahoMqtt::Packet
- PahoMqtt::Packet::Suback
- Defined in:
- lib/paho.mqtt/packet_manager.rb
Overview
Class representing an MQTT Subscribe Acknowledgment packet
Constant Summary collapse
- ATTR_DEFAULTS =
Default attribute values
{ :return_codes => [], }
Instance Attribute Summary collapse
-
#return_codes ⇒ Object
An array of return codes, ordered by the topics that were subscribed to.
Attributes inherited from PahoMqtt::Packet
#body_length, #flags, #id, #version
Instance Method Summary collapse
-
#encode_body ⇒ Object
Get serialisation of packet’s body.
-
#initialize(args = {}) ⇒ Suback
constructor
Create a new Subscribe Acknowledgment packet.
-
#inspect ⇒ Object
Returns a human readable string, summarising the properties of the packet.
-
#parse_body(buffer) ⇒ Object
Parse the body (variable header and payload) of a packet.
Methods inherited from PahoMqtt::Packet
create_from_header, parse, parse_header, read, #to_s, #type_id, #type_name, #update_attributes, #validate_flags
Constructor Details
#initialize(args = {}) ⇒ Suback
Create a new Subscribe Acknowledgment packet
857 858 859 |
# File 'lib/paho.mqtt/packet_manager.rb', line 857 def initialize(args={}) super(ATTR_DEFAULTS.merge(args)) end |
Instance Attribute Details
#return_codes ⇒ Object
An array of return codes, ordered by the topics that were subscribed to
849 850 851 |
# File 'lib/paho.mqtt/packet_manager.rb', line 849 def return_codes @return_codes end |
Instance Method Details
#encode_body ⇒ Object
Get serialisation of packet’s body
874 875 876 877 878 879 880 881 |
# File 'lib/paho.mqtt/packet_manager.rb', line 874 def encode_body if @return_codes.empty? raise "no granted QoS given when serialising packet" end body = encode_short(@id) return_codes.each { |qos| body += encode_bytes(qos) } return body end |
#inspect ⇒ Object
Returns a human readable string, summarising the properties of the packet
893 894 895 |
# File 'lib/paho.mqtt/packet_manager.rb', line 893 def inspect "\#<#{self.class}: 0x%2.2X, rc=%s>" % [id, return_codes.map{|rc| "0x%2.2X" % rc}.join(',')] end |
#parse_body(buffer) ⇒ Object
Parse the body (variable header and payload) of a packet
884 885 886 887 888 889 890 |
# File 'lib/paho.mqtt/packet_manager.rb', line 884 def parse_body(buffer) super(buffer) @id = shift_short(buffer) while(buffer.bytesize>0) @return_codes << shift_byte(buffer) end end |