lib/amqp/basic_client.rb in amqp-0.7.5 vs lib/amqp/basic_client.rb in amqp-0.8.0.beta1

- old
+ new

@@ -1,58 +1,27 @@ # encoding: utf-8 -require "amqp/frame" -require "amqp/protocol" +require "amq/client/adapters/event_machine" module AMQP - module BasicClient - def process_frame(frame) - if mq = channels[frame.channel] - mq.process_frame(frame) - return - end + # AMQP client implementation based on amq-client library. Left here for API compatibility + # with 0.7.x series. + # + # @note This class is not part of the public API and may be removed in the future without any warning. + class BasicClient < AMQ::Client::EventMachineClient - case frame - when Frame::Method - case method = frame.payload - when Protocol::Connection::Start - send Protocol::Connection::StartOk.new({:platform => 'Ruby/EventMachine', - :product => 'AMQP', - :information => 'http://github.com/ruby-amqp/amqp', - :version => VERSION}, - 'AMQPLAIN', - {:LOGIN => @settings[:user], - :PASSWORD => @settings[:pass]}, - 'en_US') + # + # API + # - when Protocol::Connection::Tune - send Protocol::Connection::TuneOk.new(:channel_max => 0, - :frame_max => 131072, - :heartbeat => @settings[:heartbeat] || 0) + # @api plugin + def connected? + self.opened? + end - send Protocol::Connection::Open.new(:virtual_host => @settings[:vhost], - :capabilities => '', - :insist => @settings[:insist]) - - @on_disconnect = method(:disconnected) - - when Protocol::Connection::OpenOk - @connected = true - @connection_status.call(:connected) if @connection_status - succeed(self) - - when Protocol::Connection::Close - # raise Error, "#{method.reply_text} in #{Protocol.classes[method.class_id].methods[method.method_id]}" - STDERR.puts "#{method.reply_text} in #{Protocol.classes[method.class_id].methods[method.method_id]}" - - when Protocol::Connection::CloseOk - @connected = false - @on_disconnect.call if @on_disconnect - end # when - - when Frame::Heartbeat - @last_server_heartbeat = Time.now - - end # case - end # def process_frame - end # BasicClient -end # AMQP + # @api plugin + def reconnect(force = false) + # TODO + raise NotImplementedError.new + end # reconnect(force = false) + end +end \ No newline at end of file