Sha256: 9937e38989e4387c64bd954a83c0de5ca7eb013fa45234be2209628c9cd8608f

Contents?: true

Size: 934 Bytes

Versions: 3

Compression:

Stored size: 934 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, [{name: 'AsyncAGI', [:[], 'SubEvent'] => 'Start'}, {name: 'AsyncAGIExec'}] do |event|
              send_complete_event complete_reason
            end
            call.redirect_back
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
punchblock-2.7.2 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.7.1 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb
punchblock-2.7.0 lib/punchblock/translator/asterisk/component/stop_by_redirect.rb