Class: Punchblock::Translator::Asterisk::Component::Output
- Includes:
- StopByRedirect
- Defined in:
- lib/punchblock/translator/asterisk/component/output.rb
Constant Summary collapse
- UnrenderableDocError =
Class.new OptionError
Instance Attribute Summary
Attributes inherited from Component
#call, #call_id, #id, #internal
Instance Method Summary collapse
Methods included from StopByRedirect
#execute_command, #stop_by_redirect
Methods inherited from Component
#call_ended, #execute_command, #initialize, #logger_id, #send_complete_event, #send_event
Methods included from DeadActorSafety
Constructor Details
This class inherits a constructor from Punchblock::Translator::Asterisk::Component::Component
Instance Method Details
#execute ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/punchblock/translator/asterisk/component/output.rb', line 18 def execute raise OptionError, 'An SSML document is required.' unless @component_node.ssml raise OptionError, 'An interrupt-on value of speech is unsupported.' if @component_node.interrupt_on == :speech [:start_offset, :start_paused, :repeat_interval, :repeat_times, :max_time].each do |opt| raise OptionError, "A #{opt} value is unsupported on Asterisk." if @component_node.send opt end early = !@call.answered? output_component = current_actor case @media_engine when :asterisk, nil raise OptionError, "A voice value is unsupported on Asterisk." if @component_node.voice raise OptionError, 'Interrupt digits are not allowed with early media.' if early && @component_node.interrupt_on case @component_node.interrupt_on when :any, :dtmf interrupt = true end path = filenames.join '&' send_ref @call.send_progress if early if interrupt call.register_handler :ami, :name => 'DTMF' do |event| output_component.stop_by_redirect Punchblock::Component::Output::Complete::Success.new if event['End'] == 'Yes' end end opts = early ? "#{path},noanswer" : path playback opts when :unimrcp send_ref @call.send_agi_action! 'EXEC MRCPSynth', escaped_doc, do |complete_event| output_component.send_complete_event! success_reason end when :swift send_ref @call.send_agi_action! 'EXEC Swift', swift_doc do |complete_event| output_component.send_complete_event! success_reason end end rescue UnrenderableDocError => e with_error 'unrenderable document error', e. rescue OptionError => e with_error 'option error', e. end |
#setup ⇒ Object
14 15 16 |
# File 'lib/punchblock/translator/asterisk/component/output.rb', line 14 def setup @media_engine = @call.translator.media_engine end |