class PahoMqtt::Packet::Suback

Constants

ATTR_DEFAULTS

Default attribute values

Attributes

return_codes[RW]

An array of return codes, ordered by the topics that were subscribed to

Public Class Methods

new(args={}) click to toggle source

Create a new Subscribe Acknowledgment packet

Calls superclass method PahoMqtt::Packet::Base::new
# File lib/paho_mqtt/packet/suback.rb, line 32
def initialize(args={})
  super(ATTR_DEFAULTS.merge(args))
end

Public Instance Methods

encode_body() click to toggle source

Get serialisation of packet's body

# File lib/paho_mqtt/packet/suback.rb, line 50
def encode_body
  if @return_codes.empty?
    raise PahoMqtt::PacketFormatException.new(
            "No granted QoS given when serialising packet")
  end
  body = encode_short(@id)
  return_codes.each { |qos| body += encode_bytes(qos) }
  return body
end
inspect() click to toggle source

Returns a human readable string, summarising the properties of the packet

# File lib/paho_mqtt/packet/suback.rb, line 70
def inspect
  "\#<#{self.class}: 0x%2.2X, rc=%s>" % [id, return_codes.map { |rc| "0x%2.2X" % rc }.join(',')]
end
parse_body(buffer) click to toggle source

Parse the body (variable header and payload) of a packet

Calls superclass method PahoMqtt::Packet::Base#parse_body
# File lib/paho_mqtt/packet/suback.rb, line 61
def parse_body(buffer)
  super(buffer)
  @id = shift_short(buffer)
  while buffer.bytesize > 0
    @return_codes << shift_byte(buffer)
  end
end
return_codes=(value) click to toggle source

Set the granted QoS value for each of the topics that were subscribed to Can either be an integer or an array or integers.

# File lib/paho_mqtt/packet/suback.rb, line 38
def return_codes=(value)
  if value.is_a?(Array)
    @return_codes = value
  elsif value.is_a?(Integer)
    @return_codes = [value]
  else
    raise PahoMqtt::PacketFormatException.new(
            "return_codes should be an integer or an array of return codes")
  end
end