class MQTT::MQTT::MQTT::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
# File lib/mqttbridge/packet.rb, line 880 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/mqttbridge/packet.rb, line 899 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
granted_qos()
click to toggle source
@deprecated Please use {#return_codes} instead
# File lib/mqttbridge/packet.rb, line 927 def granted_qos #~ puts __LINE__ return_codes end
granted_qos=(args)
click to toggle source
@deprecated Please use {#return_codes=} instead
# File lib/mqttbridge/packet.rb, line 933 def granted_qos=(args) #~ puts __LINE__ #~ puts args self.return_codes = args end
inspect()
click to toggle source
Returns a human readable string, summarising the properties of the packet
# File lib/mqttbridge/packet.rb, line 919 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
# File lib/mqttbridge/packet.rb, line 909 def parse_body(buffer) super(buffer) @id = shift_short(buffer) while(buffer.bytesize>0) @return_codes << shift_byte(buffer) end @return_codes 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/mqttbridge/packet.rb, line 886 def return_codes=(value) if value.is_a?(Array) @return_codes = value #~ puts @return_codes elsif value.is_a?(Integer) @return_codes = [value] #~ puts @return_codes else raise "return_codes should be an integer or an array of return codes" end end