Sha256: e491304d554dc160b028a7f22ca84d4f88406532a04060fe4046c817d5a70945

Contents?: true

Size: 992 Bytes

Versions: 14

Compression:

Stored size: 992 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)
            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

          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.async.send_complete_event complete_reason
            end
            call.async.redirect_back
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
punchblock-2.1.1 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.1.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.0.2 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.0.1 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.0.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.0.0.beta2 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.0.0.beta1 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-1.9.4 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-1.9.3 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-1.9.2 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-1.9.1 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-1.9.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-1.8.2 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-1.8.1 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb