Module: Punchblock::Translator::Asterisk::Component::StopByRedirect

Included in:
ComposedPrompt, MRCPNativePrompt, MRCPPrompt, Output
Defined in:
lib/punchblock/translator/asterisk/component/stop_by_redirect.rb

Instance Method Summary collapse

Instance Method Details

#execute_command(command) ⇒ Object


10
11
12
13
14
15
16
17
18
# File 'lib/punchblock/translator/asterisk/component/stop_by_redirect.rb', line 10

def execute_command(command)
  return super unless command.is_a?(Punchblock::Component::Stop)
  if @complete
    command.response = ProtocolError.new.setup 'component-already-stopped', "Component #{id} is already stopped", call_id, id
  else
    stop_by_redirect Punchblock::Event::Complete::Stop.new
    command.response = true
  end
end

#stop_by_redirect(complete_reason) ⇒ Object


20
21
22
23
24
25
# File 'lib/punchblock/translator/asterisk/component/stop_by_redirect.rb', line 20

def stop_by_redirect(complete_reason)
  call.register_handler :ami, lambda { |e| e['SubEvent'] == 'Start' }, :name => 'AsyncAGI' do |event|
    send_complete_event complete_reason
  end
  call.redirect_back
end