# encoding: utf-8 require "amqp/frame" require "amqp/protocol" module AMQP module BasicClient def process_frame(frame) if mq = channels[frame.channel] mq.process_frame(frame) return end 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') when Protocol::Connection::Tune send Protocol::Connection::TuneOk.new(:channel_max => 0, :frame_max => 131072, :heartbeat => @settings[:heartbeat] || 0) 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