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, read_byte, #to_s, #type_id, #type_name, #update_attributes
Constructor Details
#initialize(args = {}) ⇒ Pubrel
Create a new Pubrel packet
681 682 683 |
# File 'lib/mqtt/packet.rb', line 681 def initialize(args = {}) super(ATTR_DEFAULTS.merge(args)) end |
Instance Method Details
#encode_body ⇒ Object
Get serialisation of packet’s body
686 687 688 |
# File 'lib/mqtt/packet.rb', line 686 def encode_body encode_short(@id) end |
#inspect ⇒ Object
Returns a human readable string, summarising the properties of the packet
707 708 709 |
# File 'lib/mqtt/packet.rb', line 707 def inspect "\#<#{self.class}: 0x%2.2X>" % id end |
#parse_body(buffer) ⇒ Object
Parse the body (variable header and payload) of a packet
691 692 693 694 695 696 697 |
# File 'lib/mqtt/packet.rb', line 691 def parse_body(buffer) super(buffer) @id = shift_short(buffer) return if buffer.empty? raise ProtocolException, 'Extra bytes at end of Publish Release packet' end |
#validate_flags ⇒ Object
Check that fixed header flags are valid for this packet type
701 702 703 704 |
# File 'lib/mqtt/packet.rb', line 701 def validate_flags return if @flags == [false, true, false, false] raise ProtocolException, 'Invalid flags in PUBREL packet header' end |