Sha256: d7fd8d9cc1d34878988c0908ce48ca5223c9d36493f69efd0c09be56c25fa5b6

Contents?: true

Size: 784 Bytes

Versions: 2

Compression:

Stored size: 784 Bytes

Contents

# encoding: utf-8

require 'active_support/core_ext/string/filters'

module Punchblock
  module Translator
    class Asterisk
      module Component
        module StopByRedirect
          def execute_command(command)
            return super unless command.is_a?(Punchblock::Component::Stop)
            stop_by_redirect Punchblock::Event::Complete::Stop.new
            command.response = true
          end

          def stop_by_redirect(complete_reason)
            component_actor = current_actor
            call.register_handler :ami, lambda { |e| e['SubEvent'] == 'Start' }, :name => 'AsyncAGI' do |event|
              component_actor.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
punchblock-1.4.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-1.3.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb