Module: Adhearsion::Translator::Asterisk::Component::StopByRedirect

Included in:
ComposedPrompt, MRCPNativePrompt, MRCPPrompt, Output
Defined in:
lib/adhearsion/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/adhearsion/translator/asterisk/component/stop_by_redirect.rb', line 10

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

#stop_by_redirect(complete_reason) ⇒ Object


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

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