Sha256: 92adc9346e985779b001b938b1df81899901d5b1bc2ddc78fea8e5f73e2f0009

Contents?: true

Size: 1005 Bytes

Versions: 2

Compression:

Stored size: 1005 Bytes

Contents

module AMQP
  VERSION = '0.5.3'

  DIR = File.expand_path(File.dirname(File.expand_path(__FILE__)))
  $:.unshift DIR
  
  require 'ext/em'
  require 'ext/blankslate'
  
  %w[ buffer spec protocol frame client ].each do |file|
    require "amqp/#{file}"
  end

  class << self
    @logging = false
    attr_accessor :logging
    attr_reader :stopping
  end

  def self.settings
    @settings ||= {
      :user => 'guest',
      :pass => 'guest',
      :vhost => '/'
    }
  end

  def self.start *args
    @conn ||= Client.connect *args
  end
  
  def self.stop stop_reactor = true, &on_stop
    if @conn
      @conn.callback{ |c|
        if c.channels.keys.any?
          c.channels.each do |_, mq|
            mq.close
          end
        else
          c.close
        end
      }
      @on_stop = proc{
        @conn = nil
        on_stop.call if on_stop
        EM.stop_event_loop if stop_reactor
      }
    end
  end
  
  def self.stopped
    @on_stop.call if @on_stop
    @on_stop = nil
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
tmm1-amqp-0.5.3 lib/amqp.rb
amqp-0.5.3 lib/amqp.rb