Sha256: 765801df7b618739f2a4fba96d630f25a7d399e330b496be43a18a24abd8159b

Contents?: true

Size: 920 Bytes

Versions: 12

Compression:

Stored size: 920 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)
            call.register_handler :ami, lambda { |e| e['SubEvent'] == 'Start' }, :name => 'AsyncAGI' do |event|
              send_complete_event complete_reason
            end
            call.redirect_back
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
punchblock-2.6.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.5.3 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.5.2 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.5.1 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.5.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.4.2 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.4.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.3.1 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.3.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.2.2 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.2.1 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.2.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb