class MQTT::Packet::Suback
Constants
- ATTR_DEFAULTS
Default attribute values
Attributes
return_codes[R]
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
MQTT::Packet::new
# File lib/mqtt/packet.rb, line 838 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/mqtt/packet.rb, line 856 def encode_body raise 'no granted QoS given when serialising packet' if @return_codes.empty? body = encode_short(@id) return_codes.each { |qos| body += encode_bytes(qos) } body end
granted_qos()
click to toggle source
@deprecated Please use {#return_codes} instead
# File lib/mqtt/packet.rb, line 879 def granted_qos return_codes end
granted_qos=(args)
click to toggle source
@deprecated Please use {#return_codes=} instead
# File lib/mqtt/packet.rb, line 884 def granted_qos=(args) self.return_codes = args end
inspect()
click to toggle source
Returns a human readable string, summarising the properties of the packet
# File lib/mqtt/packet.rb, line 872 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
MQTT::Packet#parse_body
# File lib/mqtt/packet.rb, line 865 def parse_body(buffer) super(buffer) @id = shift_short(buffer) @return_codes << shift_byte(buffer) while buffer.bytesize > 0 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/mqtt/packet.rb, line 844 def return_codes=(value) case value when Array @return_codes = value when Integer @return_codes = [value] else raise 'return_codes should be an integer or an array of return codes' end end