Class: MQTT::Packet::Pubrel
- Inherits:
-
MQTT::Packet
- Object
- MQTT::Packet
- MQTT::Packet::Pubrel
- Defined in:
- lib/mqtt/packet.rb
Overview
Class representing an MQTT Publish Release packet
Constant Summary collapse
- ATTR_DEFAULTS =
Default attribute values
{ :flags => [false, true, false, false], }
Instance Attribute Summary
Attributes inherited from MQTT::Packet
#body_length, #flags, #id, #version
Instance Method Summary collapse
-
#encode_body ⇒ Object
Get serialisation of packet’s body.
-
#initialize(args = {}) ⇒ Pubrel
constructor
Create a new Pubrel 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.
-
#validate_flags ⇒ Object
Check that fixed header flags are valid for this packet type.
Methods inherited from MQTT::Packet
create_from_header, #message_id, #message_id=, parse, parse_header, read, #to_s, #type_id, #type_name, #update_attributes
Constructor Details
#initialize(args = {}) ⇒ Pubrel
Create a new Pubrel packet
711 712 713 |
# File 'lib/mqtt/packet.rb', line 711 def initialize(args={}) super(ATTR_DEFAULTS.merge(args)) end |
Instance Method Details
#encode_body ⇒ Object
Get serialisation of packet’s body
716 717 718 |
# File 'lib/mqtt/packet.rb', line 716 def encode_body encode_short(@id) end |
#inspect ⇒ Object
Returns a human readable string, summarising the properties of the packet
738 739 740 |
# File 'lib/mqtt/packet.rb', line 738 def inspect "\#<#{self.class}: 0x%2.2X>" % id end |
#parse_body(buffer) ⇒ Object
Parse the body (variable header and payload) of a packet
721 722 723 724 725 726 727 |
# File 'lib/mqtt/packet.rb', line 721 def parse_body(buffer) super(buffer) @id = shift_short(buffer) unless buffer.empty? raise ProtocolException.new("Extra bytes at end of Publish Release packet") end end |
#validate_flags ⇒ Object
Check that fixed header flags are valid for this packet type
731 732 733 734 735 |
# File 'lib/mqtt/packet.rb', line 731 def validate_flags if @flags != [false, true, false, false] raise ProtocolException.new("Invalid flags in PUBREL packet header") end end |