Class: Punchblock::Translator::Asterisk::Component::Asterisk::AGICommand

Inherits:
Component
  • Object
show all
Defined in:
lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb

Instance Attribute Summary

Attributes inherited from Component

#call, #call_id, #id

Instance Method Summary (collapse)

Methods inherited from Component

#call_ended, #execute_command, #initialize, #logger_id, #send_complete_event, #send_event

Constructor Details

This class inherits a constructor from Punchblock::Translator::Asterisk::Component::Component

Instance Method Details

- (Object) execute



13
14
15
16
17
18
19
20
# File 'lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb', line 13

def execute
  @agi.execute ami_client
  send_ref
rescue RubyAMI::Error
  set_node_response false
rescue ChannelGoneError
  set_node_response ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{call_id}", call_id)
end

- (Object) handle_ami_event(event)



22
23
24
25
26
27
28
29
# File 'lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb', line 22

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

- (Object) setup



9
10
11
# File 'lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb', line 9

def setup
  @agi = Punchblock::Translator::Asterisk::AGICommand.new id, @call.channel, @component_node.name, *@component_node.params
end