Class: MQTT::Packet::Unsuback

Inherits:
MQTT::Packet show all
Defined in:
lib/qubitro-mqtt/packet.rb

Overview

Class representing an MQTT Unsubscribe Acknowledgment packet

Constant Summary

Constants inherited from MQTT::Packet

ATTR_DEFAULTS

Instance Attribute Summary

Attributes inherited from MQTT::Packet

#body_length, #flags, #id, #version

Instance Method Summary collapse

Methods inherited from MQTT::Packet

create_from_header, #message_id, #message_id=, parse, parse_header, read, read_byte, #to_s, #type_id, #type_name, #update_attributes, #validate_flags

Constructor Details

#initialize(args = {}) ⇒ Unsuback

Create a new Unsubscribe Acknowledgment packet



947
948
949
# File 'lib/qubitro-mqtt/packet.rb', line 947

def initialize(args = {})
  super(args)
end

Instance Method Details

#encode_bodyObject

Get serialisation of packet’s body



952
953
954
# File 'lib/qubitro-mqtt/packet.rb', line 952

def encode_body
  encode_short(@id)
end

#inspectObject

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



966
967
968
# File 'lib/qubitro-mqtt/packet.rb', line 966

def inspect
  "\#<#{self.class}: 0x%2.2X>" % id
end

#parse_body(buffer) ⇒ Object

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

Raises:



957
958
959
960
961
962
963
# File 'lib/qubitro-mqtt/packet.rb', line 957

def parse_body(buffer)
  super(buffer)
  @id = shift_short(buffer)
  
  return if buffer.empty?
  raise ProtocolException, 'Extra bytes at end of Unsubscribe Acknowledgment packet'
end