Sha256: bc5f9bb58aa0be9b05e9309fca7ca6d991daed4a21768723b723baa551d1de17

Contents?: true

Size: 847 Bytes

Versions: 11

Compression:

Stored size: 847 Bytes

Contents

# encoding: utf-8

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, options[:media_engine]
        super()
      end

      def run
        ami_client.start
        raise DisconnectedError
      end

      def stop
        translator.shutdown!
        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

11 entries across 11 versions & 1 rubygems

Version Path
punchblock-1.8.0 lib/punchblock/connection/asterisk.rb
punchblock-1.7.1 lib/punchblock/connection/asterisk.rb
punchblock-1.7.0 lib/punchblock/connection/asterisk.rb
punchblock-1.6.1 lib/punchblock/connection/asterisk.rb
punchblock-1.6.0 lib/punchblock/connection/asterisk.rb
punchblock-1.5.3 lib/punchblock/connection/asterisk.rb
punchblock-1.5.2 lib/punchblock/connection/asterisk.rb
punchblock-1.5.1 lib/punchblock/connection/asterisk.rb
punchblock-1.5.0 lib/punchblock/connection/asterisk.rb
punchblock-1.4.1 lib/punchblock/connection/asterisk.rb
punchblock-1.4.0 lib/punchblock/connection/asterisk.rb