Sha256: 89b67903439d53d23552c9f1e6f2e67ad0f08f1473ff7557f9d14301322f7347

Contents?: true

Size: 797 Bytes

Versions: 6

Compression:

Stored size: 797 Bytes

Contents

require 'ruby_ami'

module Punchblock
  module Connection
    class Asterisk < GenericConnection
      attr_reader :ami_client, :translator
      attr_accessor :event_handler

      def initialize(options = {})
        @ami_client = RubyAMI::Client.new options.merge(:event_handler => lambda { |event| translator.handle_ami_event! event }, :logger => pb_logger)
        @translator = Translator::Asterisk.new @ami_client, self
        super()
      end

      def run
        pb_logger.debug "Starting the RubyAMI client"
        ami_client.start
      end

      def stop
        ami_client.stop
      end

      def write(command, options)
        translator.execute_command! command, options
      end

      def handle_event(event)
        event_handler.call event
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
punchblock-0.8.2 lib/punchblock/connection/asterisk.rb
punchblock-0.8.1 lib/punchblock/connection/asterisk.rb
punchblock-0.8.0 lib/punchblock/connection/asterisk.rb
punchblock-0.7.2 lib/punchblock/connection/asterisk.rb
punchblock-0.7.1 lib/punchblock/connection/asterisk.rb
punchblock-0.7.0 lib/punchblock/connection/asterisk.rb