lib/amq/protocol/client.rb in amq-protocol-1.5.0 vs lib/amq/protocol/client.rb in amq-protocol-1.6.0

- old
+ new

@@ -2,107 +2,34 @@ # THIS IS AN AUTOGENERATED FILE, DO NOT MODIFY # IT DIRECTLY ! FOR CHANGES, PLEASE UPDATE FILES # IN THE ./codegen DIRECTORY OF THE AMQ-PROTOCOL REPOSITORY. +require "amq/pack" + require "amq/protocol/table" require "amq/protocol/frame" -require "amq/hacks" +require "amq/protocol/constants" +require "amq/protocol/exceptions" + module AMQ module Protocol PROTOCOL_VERSION = "0.9.1".freeze PREAMBLE = "AMQP\x00\x00\x09\x01".freeze DEFAULT_PORT = 5672 - TLS_PORT = 5671 - 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 = 'G'.freeze - - - # @return [Array] Collection of subclasses of AMQ::Protocol::Class. def self.classes Protocol::Class.classes end # @return [Array] Collection of subclasses of AMQ::Protocol::Method. def self.methods Protocol::Method.methods end - class Error < StandardError - DEFAULT_MESSAGE = "AMQP error".freeze - - def self.inherited(subclass) - @_subclasses ||= [] - @_subclasses << subclass - end # self.inherited(subclazz) - - def self.subclasses_with_values - @_subclasses.select{ |k| defined?(k::VALUE) } - end # self.subclasses_with_values - - def self.[](code) - if result = subclasses_with_values.detect { |klass| klass::VALUE == code } - result - else - raise "No such exception class for code #{code}" unless result - end # if - end # self.[] - - def initialize(message = self.class::DEFAULT_MESSAGE) - super(message) - end - end - - class FrameTypeError < Protocol::Error - def initialize(types) - super("Must be one of #{types.inspect}") - end - end - - class EmptyResponseError < Protocol::Error - DEFAULT_MESSAGE = "Empty response received from the server." - - def initialize(message = self.class::DEFAULT_MESSAGE) - super(message) - end - end - - class BadResponseError < Protocol::Error - def initialize(argument, expected, actual) - super("Argument #{argument} has to be #{expected.inspect}, was #{data.inspect}") - end - end - - class SoftError < Protocol::Error - def self.inherited(subclass) - Error.inherited(subclass) - end # self.inherited(subclass) - end - - class HardError < Protocol::Error - def self.inherited(subclass) - Error.inherited(subclass) - end # self.inherited(subclass) - end - class ContentTooLarge < SoftError VALUE = 311 end class NoRoute < SoftError @@ -172,25 +99,10 @@ class InternalError < HardError VALUE = 541 end - # We don't instantiate the following classes, - # as we don't actually need any per-instance state. - # Also, this is pretty low-level functionality, - # hence it should have a reasonable performance. - # As everyone knows, garbage collector in MRI performs - # really badly, which is another good reason for - # not creating any objects, but only use class as - # a struct. Creating classes is quite expensive though, - # but here the inheritance comes handy and mainly - # as we can't simply make a reference to a function, - # we can't use a hash or an object. I've been also - # considering to have just a bunch of methods, but - # here's the problem, that after we'd require this file, - # all these methods would become global which would - # be a bad, bad thing to do. class Class @classes = Array.new def self.method_id @method_id @@ -256,36 +168,27 @@ # 1 byte of frame type # 2 bytes of channel number # 4 bytes of frame payload length # 1 byte of payload trailer FRAME_END byte limit = frame_size - 8 + return [BodyFrame.new(body, channel)] if body.bytesize < limit # Otherwise String#slice on 1.9 will operate with code points, # and we need bytes. MK. 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 - # We can return different: - # - instantiate given subclass of Method - # - create an OpenStruct object - # - create a hash - # - yield params into the block rather than just return - # @api plugin def self.instantiate(*args, &block) self.new(*args, &block) - # or OpenStruct.new(args.first) - # or args.first - # or block.call(*args) end end class Connection < Protocol::Class @name = "connection" @@ -349,12 +252,11 @@ # @return # [u'client_properties = nil', u"mechanism = u'PLAIN'", u'response = nil', u"locale = u'en_US'"] def self.encode(client_properties, mechanism, response, locale) channel = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << AMQ::Protocol::Table.encode(client_properties) buffer << mechanism.to_s.bytesize.chr buffer << mechanism.to_s buffer << [response.to_s.bytesize].pack(PACK_UINT32) buffer << response.to_s @@ -406,12 +308,11 @@ # @return # [u'response = nil'] def self.encode(response) channel = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [response.to_s.bytesize].pack(PACK_UINT32) buffer << response.to_s MethodFrame.new(buffer, channel) end @@ -462,12 +363,11 @@ # @return # [u'channel_max = false', u'frame_max = false', u'heartbeat = false'] def self.encode(channel_max, frame_max, heartbeat) channel = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [channel_max].pack(PACK_UINT16) buffer << [frame_max].pack(PACK_UINT32) buffer << [heartbeat].pack(PACK_UINT16) MethodFrame.new(buffer, channel) end @@ -489,12 +389,11 @@ # [u"virtual_host = u'/'", u'capabilities = EMPTY_STRING', u'insist = false'] def self.encode(virtual_host) capabilities = EMPTY_STRING insist = false channel = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << virtual_host.to_s.bytesize.chr buffer << virtual_host.to_s buffer << capabilities.to_s.bytesize.chr buffer << capabilities.to_s bit_buffer = 0 @@ -569,12 +468,11 @@ # @return # [u'reply_code = nil', u'reply_text = EMPTY_STRING', u'class_id = nil', u'method_id = nil'] def self.encode(reply_code, reply_text, class_id, method_id) channel = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [reply_code].pack(PACK_UINT16) buffer << reply_text.to_s.bytesize.chr buffer << reply_text.to_s buffer << [class_id].pack(PACK_UINT16) buffer << [method_id].pack(PACK_UINT16) @@ -604,12 +502,11 @@ # @return # [] def self.encode() channel = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup MethodFrame.new(buffer, channel) end end @@ -633,12 +530,11 @@ end # @return # [u'out_of_band = EMPTY_STRING'] def self.encode(channel, out_of_band) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << out_of_band.to_s.bytesize.chr buffer << out_of_band.to_s MethodFrame.new(buffer, channel) end @@ -697,12 +593,11 @@ end # @return # [u'active = nil'] def self.encode(channel, active) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if active buffer << [bit_buffer].pack(PACK_CHAR) MethodFrame.new(buffer, channel) end @@ -734,12 +629,11 @@ end # @return # [u'active = nil'] def self.encode(channel, active) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if active buffer << [bit_buffer].pack(PACK_CHAR) MethodFrame.new(buffer, channel) end @@ -781,12 +675,11 @@ end # @return # [u'reply_code = nil', u'reply_text = EMPTY_STRING', u'class_id = nil', u'method_id = nil'] def self.encode(channel, reply_code, reply_text, class_id, method_id) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [reply_code].pack(PACK_UINT16) buffer << reply_text.to_s.bytesize.chr buffer << reply_text.to_s buffer << [class_id].pack(PACK_UINT16) buffer << [method_id].pack(PACK_UINT16) @@ -815,12 +708,11 @@ end # @return # [] def self.encode(channel) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup MethodFrame.new(buffer, channel) end end @@ -845,12 +737,11 @@ # @return # [u'ticket = 0', u'exchange = nil', u"type = u'direct'", u'passive = false', u'durable = false', u'auto_delete = false', u'internal = false', u'nowait = false', u'arguments = {}'] def self.encode(channel, exchange, type, passive, durable, auto_delete, internal, nowait, arguments) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << exchange.to_s.bytesize.chr buffer << exchange.to_s buffer << type.to_s.bytesize.chr buffer << type.to_s @@ -902,12 +793,11 @@ # @return # [u'ticket = 0', u'exchange = nil', u'if_unused = false', u'nowait = false'] def self.encode(channel, exchange, if_unused, nowait) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << exchange.to_s.bytesize.chr buffer << exchange.to_s bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if if_unused @@ -953,12 +843,11 @@ # @return # [u'ticket = 0', u'destination = nil', u'source = nil', u'routing_key = EMPTY_STRING', u'nowait = false', u'arguments = {}'] def self.encode(channel, destination, source, routing_key, nowait, arguments) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << destination.to_s.bytesize.chr buffer << destination.to_s buffer << source.to_s.bytesize.chr buffer << source.to_s @@ -1008,12 +897,11 @@ # @return # [u'ticket = 0', u'destination = nil', u'source = nil', u'routing_key = EMPTY_STRING', u'nowait = false', u'arguments = {}'] def self.encode(channel, destination, source, routing_key, nowait, arguments) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << destination.to_s.bytesize.chr buffer << destination.to_s buffer << source.to_s.bytesize.chr buffer << source.to_s @@ -1071,12 +959,11 @@ # @return # [u'ticket = 0', u'queue = EMPTY_STRING', u'passive = false', u'durable = false', u'exclusive = false', u'auto_delete = false', u'nowait = false', u'arguments = {}'] def self.encode(channel, queue, passive, durable, exclusive, auto_delete, nowait, arguments) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << queue.to_s.bytesize.chr buffer << queue.to_s bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if passive @@ -1138,12 +1025,11 @@ # @return # [u'ticket = 0', u'queue = EMPTY_STRING', u'exchange = nil', u'routing_key = EMPTY_STRING', u'nowait = false', u'arguments = {}'] def self.encode(channel, queue, exchange, routing_key, nowait, arguments) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << queue.to_s.bytesize.chr buffer << queue.to_s buffer << exchange.to_s.bytesize.chr buffer << exchange.to_s @@ -1193,12 +1079,11 @@ # @return # [u'ticket = 0', u'queue = EMPTY_STRING', u'nowait = false'] def self.encode(channel, queue, nowait) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << queue.to_s.bytesize.chr buffer << queue.to_s bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if nowait @@ -1247,12 +1132,11 @@ # @return # [u'ticket = 0', u'queue = EMPTY_STRING', u'if_unused = false', u'if_empty = false', u'nowait = false'] def self.encode(channel, queue, if_unused, if_empty, nowait) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << queue.to_s.bytesize.chr buffer << queue.to_s bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if if_unused @@ -1303,12 +1187,11 @@ # @return # [u'ticket = 0', u'queue = EMPTY_STRING', u'exchange = nil', u'routing_key = EMPTY_STRING', u'arguments = {}'] def self.encode(channel, queue, exchange, routing_key, arguments) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << queue.to_s.bytesize.chr buffer << queue.to_s buffer << exchange.to_s.bytesize.chr buffer << exchange.to_s @@ -1435,11 +1318,11 @@ end # 1 << 6 def self.encode_timestamp(value) buffer = '' - buffer << AMQ::Hacks.pack_uint64_big_endian(value) + buffer << AMQ::Pack.pack_uint64_big_endian(value) [9, 0x0040, buffer] end # 1 << 5 def self.encode_type(value) @@ -1484,11 +1367,11 @@ pieces[i] = result end # result = [60, 0, body_size, flags].pack('n2Qn') result = [60, 0].pack(PACK_UINT16_X2) - result += AMQ::Hacks.pack_uint64_big_endian(body_size) + result += AMQ::Pack.pack_uint64_big_endian(body_size) result += [flags].pack(PACK_UINT16) result + pieces.join(EMPTY_STRING) end # THIS DECODES ONLY FLAGS @@ -1590,12 +1473,11 @@ end # @return # [u'prefetch_size = false', u'prefetch_count = false', u'global = false'] def self.encode(channel, prefetch_size, prefetch_count, global) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [prefetch_size].pack(PACK_UINT32) buffer << [prefetch_count].pack(PACK_UINT16) bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if global buffer << [bit_buffer].pack(PACK_CHAR) @@ -1639,12 +1521,11 @@ # @return # [u'ticket = 0', u'queue = EMPTY_STRING', u'consumer_tag = EMPTY_STRING', u'no_local = false', u'no_ack = false', u'exclusive = false', u'nowait = false', u'arguments = {}'] def self.encode(channel, queue, consumer_tag, no_local, no_ack, exclusive, nowait, arguments) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << queue.to_s.bytesize.chr buffer << queue.to_s buffer << consumer_tag.to_s.bytesize.chr buffer << consumer_tag.to_s @@ -1718,12 +1599,11 @@ end # @return # [u'consumer_tag = nil', u'nowait = false'] def self.encode(channel, consumer_tag, nowait) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << consumer_tag.to_s.bytesize.chr buffer << consumer_tag.to_s bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if nowait buffer << [bit_buffer].pack(PACK_CHAR) @@ -1773,12 +1653,11 @@ # @return # [u'ticket = 0', u'exchange = EMPTY_STRING', u'routing_key = EMPTY_STRING', u'mandatory = false', u'immediate = false', 'user_headers = nil', 'payload = ""', 'frame_size = nil'] def self.encode(channel, payload, user_headers, exchange, routing_key, mandatory, immediate, frame_size) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << exchange.to_s.bytesize.chr buffer << exchange.to_s buffer << routing_key.to_s.bytesize.chr buffer << routing_key.to_s @@ -1786,13 +1665,12 @@ bit_buffer = bit_buffer | (1 << 0) if mandatory bit_buffer = bit_buffer | (1 << 1) if immediate buffer << [bit_buffer].pack(PACK_CHAR) frames = [MethodFrame.new(buffer, channel)] properties, headers = self.split_headers(user_headers) - # TODO: what shall I do with the headers? if properties.nil? or properties.empty? - raise RuntimeError.new("Properties can not be empty!") # TODO: or can they? + raise RuntimeError.new("Properties can not be empty!") end properties_payload = Basic.encode_properties(payload.bytesize, properties) frames << HeaderFrame.new(properties_payload, channel) frames += self.encode_body(payload, channel, frame_size) frames @@ -1852,11 +1730,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_uint64_big_endian(data[offset, 8]).first + delivery_tag = AMQ::Pack.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 @@ -1899,12 +1777,11 @@ # @return # [u'ticket = 0', u'queue = EMPTY_STRING', u'no_ack = false'] def self.encode(channel, queue, no_ack) ticket = 0 - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [ticket].pack(PACK_UINT16) buffer << queue.to_s.bytesize.chr buffer << queue.to_s bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if no_ack @@ -1921,11 +1798,11 @@ @packed_indexes = [60, 71].pack(PACK_UINT16_X2).freeze # @return def self.decode(data) offset = 0 - delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first + delivery_tag = AMQ::Pack.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 @@ -1992,11 +1869,11 @@ @packed_indexes = [60, 80].pack(PACK_UINT16_X2).freeze # @return def self.decode(data) offset = 0 - delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first + delivery_tag = AMQ::Pack.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) @@ -2013,13 +1890,12 @@ end # @return # [u'delivery_tag = false', u'multiple = false'] def self.encode(channel, delivery_tag, multiple) - buffer = '' - buffer << @packed_indexes - buffer << AMQ::Hacks.pack_uint64_big_endian(delivery_tag) + buffer = @packed_indexes.dup + buffer << AMQ::Pack.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 @@ -2038,13 +1914,12 @@ end # @return # [u'delivery_tag = nil', u'requeue = true'] def self.encode(channel, delivery_tag, requeue) - buffer = '' - buffer << @packed_indexes - buffer << AMQ::Hacks.pack_uint64_big_endian(delivery_tag) + buffer = @packed_indexes.dup + buffer << AMQ::Pack.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 @@ -2063,12 +1938,11 @@ end # @return # [u'requeue = false'] def self.encode(channel, requeue) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if requeue buffer << [bit_buffer].pack(PACK_CHAR) MethodFrame.new(buffer, channel) end @@ -2087,12 +1961,11 @@ end # @return # [u'requeue = false'] def self.encode(channel, requeue) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if requeue buffer << [bit_buffer].pack(PACK_CHAR) MethodFrame.new(buffer, channel) end @@ -2128,11 +2001,11 @@ @packed_indexes = [60, 120].pack(PACK_UINT16_X2).freeze # @return def self.decode(data) offset = 0 - delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first + delivery_tag = AMQ::Pack.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 @@ -2151,13 +2024,12 @@ end # @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_uint64_big_endian(delivery_tag) + buffer = @packed_indexes.dup + buffer << AMQ::Pack.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) @@ -2198,12 +2070,11 @@ end # @return # [u'consumer_tag = EMPTY_STRING', u'credit = nil', u'drain = nil'] def self.encode(channel, consumer_tag, credit, drain) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << consumer_tag.to_s.bytesize.chr buffer << consumer_tag.to_s buffer << [credit].pack(PACK_UINT32) bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if drain @@ -2237,12 +2108,11 @@ end # @return # [u'available = nil'] def self.encode(channel, available) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << [available].pack(PACK_UINT32) MethodFrame.new(buffer, channel) end end @@ -2276,12 +2146,11 @@ end # @return # [u'consumer_tag = EMPTY_STRING', u'credit_drained = nil'] def self.encode(channel, consumer_tag, credit_drained) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup buffer << consumer_tag.to_s.bytesize.chr buffer << consumer_tag.to_s buffer << [credit_drained].pack(PACK_UINT32) MethodFrame.new(buffer, channel) end @@ -2308,12 +2177,11 @@ end # @return # [] def self.encode(channel) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup MethodFrame.new(buffer, channel) end end @@ -2351,12 +2219,11 @@ end # @return # [] def self.encode(channel) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup MethodFrame.new(buffer, channel) end end @@ -2394,12 +2261,11 @@ end # @return # [] def self.encode(channel) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup MethodFrame.new(buffer, channel) end end @@ -2458,12 +2324,11 @@ end # @return # [u'nowait = false'] def self.encode(channel, nowait) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup bit_buffer = 0 bit_buffer = bit_buffer | (1 << 0) if nowait buffer << [bit_buffer].pack(PACK_CHAR) MethodFrame.new(buffer, channel) end @@ -2490,11 +2355,10 @@ end # @return # [] def self.encode(channel) - buffer = '' - buffer << @packed_indexes + buffer = @packed_indexes.dup MethodFrame.new(buffer, channel) end end