Sha256: fac6a0c3ce526dd5ae024e75b9e69d327b97a1e2cc69c2f5d877931210a0a91a

Contents?: true

Size: 953 Bytes

Versions: 2

Compression:

Stored size: 953 Bytes

Contents

# encoding: utf-8

require 'active_support/core_ext/string/filters'

module Adhearsion
  module Translator
    class Asterisk
      module Component
        module StopByRedirect
          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

          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
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adhearsion-3.0.0.rc1 lib/adhearsion/translator/asterisk/component/stop_by_redirect.rb
adhearsion-3.0.0.beta2 lib/adhearsion/translator/asterisk/component/stop_by_redirect.rb