class AMQ::Protocol::Basic
Constants
- DECODE_PROPERTIES
THIS DECODES ONLY FLAGS
- DECODE_PROPERTIES_KEYS
Hash doesn't give any guarantees on keys order, we will do it in a straightforward way
- DECODE_PROPERTIES_TYPE
- PROPERTIES
Public Class Methods
decode_properties(data)
click to toggle source
# File lib/amq/protocol/client.rb, line 1497 def self.decode_properties(data) offset, data_length, properties = 0, data.bytesize, {} compressed_index = data[offset, 2].unpack(PACK_UINT16)[0] offset += 2 while data_length > offset DECODE_PROPERTIES_KEYS.each do |key| next unless compressed_index >= key compressed_index -= key name = DECODE_PROPERTIES[key] || raise(RuntimeError.new("No property found for index #{index.inspect}!")) case DECODE_PROPERTIES_TYPE[key] when :shortstr size = data[offset, 1].unpack(PACK_CHAR)[0] offset += 1 result = data[offset, size] when :octet size = 1 result = data[offset, size].unpack(PACK_CHAR).first when :timestamp size = 8 result = Time.at(data[offset, size].unpack(PACK_UINT32_X2).last) when :table size = 4 + data[offset, 4].unpack(PACK_UINT32)[0] result = Table.decode(data[offset, size]) end properties[name] = result offset += size end end properties end
encode_app_id(value)
click to toggle source
1 << 3
# File lib/amq/protocol/client.rb, line 1409 def self.encode_app_id(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [12, 0x0008, buffer] end
encode_cluster_id(value)
click to toggle source
1 << 2
# File lib/amq/protocol/client.rb, line 1417 def self.encode_cluster_id(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [13, 0x0004, buffer] end
encode_content_encoding(value)
click to toggle source
1 << 14
# File lib/amq/protocol/client.rb, line 1325 def self.encode_content_encoding(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [1, 0x4000, buffer] end
encode_content_type(value)
click to toggle source
1 << 15
# File lib/amq/protocol/client.rb, line 1317 def self.encode_content_type(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [0, 0x8000, buffer] end
encode_correlation_id(value)
click to toggle source
1 << 10
# File lib/amq/protocol/client.rb, line 1354 def self.encode_correlation_id(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [5, 0x0400, buffer] end
encode_delivery_mode(value)
click to toggle source
1 << 12
# File lib/amq/protocol/client.rb, line 1340 def self.encode_delivery_mode(value) buffer = '' buffer << [value].pack(PACK_CHAR) [3, 0x1000, buffer] end
encode_expiration(value)
click to toggle source
1 << 8
# File lib/amq/protocol/client.rb, line 1370 def self.encode_expiration(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [7, 0x0100, buffer] end
encode_headers(value)
click to toggle source
1 << 13
# File lib/amq/protocol/client.rb, line 1333 def self.encode_headers(value) buffer = '' buffer << AMQ::Protocol::Table.encode(value) [2, 0x2000, buffer] end
encode_message_id(value)
click to toggle source
1 << 7
# File lib/amq/protocol/client.rb, line 1378 def self.encode_message_id(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [8, 0x0080, buffer] end
encode_priority(value)
click to toggle source
1 << 11
# File lib/amq/protocol/client.rb, line 1347 def self.encode_priority(value) buffer = '' buffer << [value].pack(PACK_CHAR) [4, 0x0800, buffer] end
encode_properties(body_size, properties)
click to toggle source
# File lib/amq/protocol/client.rb, line 1426 def self.encode_properties(body_size, properties) pieces, flags = [], 0 properties.reject {|key, value| value.nil?}.each do |key, value| i, f, result = self.__send__(:"encode_#{key}", value) flags |= f pieces[i] = result end # result = [60, 0, body_size, flags].pack('n2Qn') result = [60, 0].pack(PACK_UINT16_X2) result += AMQ::Pack.pack_uint64_big_endian(body_size) result += [flags].pack(PACK_UINT16) pieces_joined = pieces.join(EMPTY_STRING) result.force_encoding(pieces_joined.encoding) + pieces_joined end
encode_reply_to(value)
click to toggle source
1 << 9
# File lib/amq/protocol/client.rb, line 1362 def self.encode_reply_to(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [6, 0x0200, buffer] end
encode_timestamp(value)
click to toggle source
1 << 6
# File lib/amq/protocol/client.rb, line 1386 def self.encode_timestamp(value) buffer = '' buffer << AMQ::Pack.pack_uint64_big_endian(value) [9, 0x0040, buffer] end
encode_type(value)
click to toggle source
1 << 5
# File lib/amq/protocol/client.rb, line 1393 def self.encode_type(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [10, 0x0020, buffer] end
encode_user_id(value)
click to toggle source
1 << 4
# File lib/amq/protocol/client.rb, line 1401 def self.encode_user_id(value) buffer = '' buffer << value.to_s.bytesize.chr buffer << value.to_s [11, 0x0010, buffer] end