Sha256: 67ac0d441e7f422da180b7297d9f333ffeb3d98d2e42b5986344cb9089f15b1e

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8

module Punchblock
  module Translator
    class Asterisk
      module Component
        module Asterisk
          class AGICommand < Component
            def setup
              @agi = Punchblock::Translator::Asterisk::AGICommand.new id, @call.channel, @component_node.name, *@component_node.params_array
            end

            def execute
              @agi.execute ami_client
              send_ref
            rescue RubyAMI::Error
              set_node_response false
              terminate
            end
            exclusive :execute

            def handle_ami_event(event)
              if event.name == 'AsyncAGI' && event['SubEvent'] == 'Exec'
                send_complete_event success_reason(event), nil, false
                if @component_node.name == 'ASYNCAGI BREAK' && @call.channel_var('PUNCHBLOCK_END_ON_ASYNCAGI_BREAK')
                  @call.handle_hangup_event
                end
                terminate
              end
            end

            private

            def success_reason(event)
              result = @agi.parse_result event
              Punchblock::Component::Asterisk::AGI::Command::Complete::Success.new result
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
punchblock-1.9.4 lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb
punchblock-1.9.3 lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb
punchblock-1.9.2 lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb
punchblock-1.9.1 lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb
punchblock-1.9.0 lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb