class Punchblock::Translator::Freeswitch::Component::Component
Attributes
call[R]
call_id[R]
id[R]
Public Class Methods
new(component_node, call = nil)
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 26 def initialize(component_node, call = nil) @component_node, @call = component_node, call @call_id = safe_from_dead_actors { call.id } if call @id = Punchblock.new_uuid @complete = false setup end
Public Instance Methods
application(appname, options = nil)
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 68 def application(appname, options = nil) call.application appname, "%[punchblock_component_id=#{id}]#{options}" end
call_ended()
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 64 def call_ended send_complete_event Punchblock::Event::Complete::Hangup.new end
execute_command(command)
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 37 def execute_command(command) command.response = ProtocolError.new.setup 'command-not-acceptable', "Did not understand command for component #{id}", call_id, id end
handle_es_event(event)
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 41 def handle_es_event(event) trigger_handler :es, event end
logger_id()
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 60 def logger_id "#{self.class}: #{call_id ? "Call ID: #{call_id}, Component ID: #{id}" : id}" end
send_complete_event(reason, recording = nil)
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 45 def send_complete_event(reason, recording = nil) return if @complete @complete = true event = Punchblock::Event::Complete.new reason: reason, recording: recording send_event event terminate end
send_event(event)
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 53 def send_event(event) event.component_id = id event.target_call_id = call_id event.source_uri = id safe_from_dead_actors { translator.handle_pb_event event } end
setup()
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 34 def setup end
Private Instance Methods
send_ref()
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 82 def send_ref set_node_response Ref.new uri: id end
set_node_response(value)
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 78 def set_node_response(value) @component_node.response = value end
translator()
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 74 def translator call.translator end
with_error(name, text)
click to toggle source
# File lib/punchblock/translator/freeswitch/component.rb, line 86 def with_error(name, text) set_node_response ProtocolError.new.setup(name, text) end