lib/amq/protocol/client.rb in amq-protocol-1.2.0 vs lib/amq/protocol/client.rb in amq-protocol-1.3.0
- old
+ new
@@ -17,27 +17,25 @@
SSL_PORT = 5671
# caching
EMPTY_STRING = "".freeze
+ PACK_INT8 = 'c'.freeze
PACK_CHAR = 'C'.freeze
PACK_UINT16 = 'n'.freeze
PACK_UINT16_X2 = 'n2'.freeze
PACK_UINT32 = 'N'.freeze
PACK_UINT32_X2 = 'N2'.freeze
PACK_INT64 = 'q'.freeze
PACK_UCHAR_UINT32 = 'CN'.freeze
PACK_CHAR_UINT16_UINT32 = 'cnN'.freeze
PACK_32BIT_FLOAT = 'f'.freeze
- PACK_64BIT_FLOAT = 'd'.freeze
+ PACK_64BIT_FLOAT = 'G'.freeze
- PACK_SIGNED_8BIT = 'c'.freeze
- PACK_SIGNED_16BIT = 's'.freeze
-
# @return [Array] Collection of subclasses of AMQ::Protocol::Class.
def self.classes
Protocol::Class.classes
end
@@ -266,10 +264,11 @@
body.force_encoding("ASCII-8BIT") if RUBY_VERSION.to_f >= 1.9
array = Array.new
while body
payload, body = body[0, limit], body[limit, body.length - limit]
+ # array << [0x03, payload]
array << BodyFrame.new(payload, channel)
end
array
end
@@ -1436,11 +1435,11 @@
end
# 1 << 6
def self.encode_timestamp(value)
buffer = ''
- buffer << AMQ::Hacks.pack_64_big_endian(value)
+ buffer << AMQ::Hacks.pack_uint64_big_endian(value)
[9, 0x0040, buffer]
end
# 1 << 5
def self.encode_type(value)
@@ -1485,11 +1484,11 @@
pieces[i] = result
end
# result = [60, 0, body_size, flags].pack('n2Qn')
result = [60, 0].pack(PACK_UINT16_X2)
- result += AMQ::Hacks.pack_64_big_endian(body_size)
+ result += AMQ::Hacks.pack_uint64_big_endian(body_size)
result += [flags].pack(PACK_UINT16)
result + pieces.join(EMPTY_STRING)
end
# THIS DECODES ONLY FLAGS
@@ -1794,11 +1793,10 @@
raise RuntimeError.new("Properties can not be empty!") # TODO: or can they?
end
properties_payload = Basic.encode_properties(payload.bytesize, properties)
frames << HeaderFrame.new(properties_payload, channel)
frames += self.encode_body(payload, channel, frame_size)
-
frames
end
end
@@ -1854,11 +1852,11 @@
offset = 0
length = data[offset, 1].unpack(PACK_CHAR).first
offset += 1
consumer_tag = data[offset, length]
offset += length
- delivery_tag = AMQ::Hacks.unpack_64_big_endian(data[offset, 8]).first
+ delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first
offset += 8
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
offset += 1
redelivered = (bit_buffer & (1 << 0)) != 0
length = data[offset, 1].unpack(PACK_CHAR).first
@@ -1923,11 +1921,11 @@
@packed_indexes = [60, 71].pack(PACK_UINT16_X2).freeze
# @return
def self.decode(data)
offset = 0
- delivery_tag = AMQ::Hacks.unpack_64_big_endian(data[offset, 8]).first
+ delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first
offset += 8
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
offset += 1
redelivered = (bit_buffer & (1 << 0)) != 0
length = data[offset, 1].unpack(PACK_CHAR).first
@@ -1994,11 +1992,11 @@
@packed_indexes = [60, 80].pack(PACK_UINT16_X2).freeze
# @return
def self.decode(data)
offset = 0
- delivery_tag = AMQ::Hacks.unpack_64_big_endian(data[offset, 8]).first
+ delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first
offset += 8
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
offset += 1
multiple = (bit_buffer & (1 << 0)) != 0
self.new(delivery_tag, multiple)
@@ -2017,11 +2015,11 @@
# @return
# [u'delivery_tag = false', u'multiple = false']
def self.encode(channel, delivery_tag, multiple)
buffer = ''
buffer << @packed_indexes
- buffer << AMQ::Hacks.pack_64_big_endian(delivery_tag)
+ buffer << AMQ::Hacks.pack_uint64_big_endian(delivery_tag)
bit_buffer = 0
bit_buffer = bit_buffer | (1 << 0) if multiple
buffer << [bit_buffer].pack(PACK_CHAR)
MethodFrame.new(buffer, channel)
end
@@ -2042,11 +2040,11 @@
# @return
# [u'delivery_tag = nil', u'requeue = true']
def self.encode(channel, delivery_tag, requeue)
buffer = ''
buffer << @packed_indexes
- buffer << AMQ::Hacks.pack_64_big_endian(delivery_tag)
+ buffer << AMQ::Hacks.pack_uint64_big_endian(delivery_tag)
bit_buffer = 0
bit_buffer = bit_buffer | (1 << 0) if requeue
buffer << [bit_buffer].pack(PACK_CHAR)
MethodFrame.new(buffer, channel)
end
@@ -2130,11 +2128,11 @@
@packed_indexes = [60, 120].pack(PACK_UINT16_X2).freeze
# @return
def self.decode(data)
offset = 0
- delivery_tag = AMQ::Hacks.unpack_64_big_endian(data[offset, 8]).first
+ delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first
offset += 8
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
offset += 1
multiple = (bit_buffer & (1 << 0)) != 0
requeue = (bit_buffer & (1 << 1)) != 0
@@ -2155,10 +2153,10 @@
# @return
# [u'delivery_tag = false', u'multiple = false', u'requeue = true']
def self.encode(channel, delivery_tag, multiple, requeue)
buffer = ''
buffer << @packed_indexes
- buffer << AMQ::Hacks.pack_64_big_endian(delivery_tag)
+ buffer << AMQ::Hacks.pack_uint64_big_endian(delivery_tag)
bit_buffer = 0
bit_buffer = bit_buffer | (1 << 0) if multiple
bit_buffer = bit_buffer | (1 << 1) if requeue
buffer << [bit_buffer].pack(PACK_CHAR)
MethodFrame.new(buffer, channel)