Sha256: 9aa7247732297e3987236633dd11035093cec41d6adfe6c85edff368f0301c33

Contents?: true

Size: 794 Bytes

Versions: 1

Compression:

Stored size: 794 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
        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

1 entries across 1 versions & 1 rubygems

Version Path
punchblock-0.6.2 lib/punchblock/connection/asterisk.rb