module Punchblock::Translator::Asterisk::Component::StopByRedirect

Public Instance Methods

execute_command(command) click to toggle source
Calls superclass method
# 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) click to toggle source
# File lib/punchblock/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