Class: Punchblock::Translator::Freeswitch::Component::Component
Instance Attribute Summary collapse
Instance Method Summary
collapse
execute_guarded_handlers_on_receiver
#safe_from_dead_actors
Constructor Details
#initialize(component_node, call = nil) ⇒ Component
Returns a new instance of Component.
26
27
28
29
30
31
32
|
# 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
|
Instance Attribute Details
Returns the value of attribute call.
24
25
26
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 24
def call
@call
end
|
Returns the value of attribute call_id.
24
25
26
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 24
def call_id
@call_id
end
|
Returns the value of attribute id.
24
25
26
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 24
def id
@id
end
|
Instance Method Details
#application(appname, options = nil) ⇒ Object
68
69
70
|
# 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 ⇒ Object
64
65
66
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 64
def call_ended
send_complete_event Punchblock::Event::Complete::Hangup.new
end
|
#execute_command(command) ⇒ Object
37
38
39
|
# 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) ⇒ Object
41
42
43
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 41
def handle_es_event(event)
trigger_handler :es, event
end
|
#logger_id ⇒ Object
60
61
62
|
# 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) ⇒ Object
45
46
47
48
49
50
51
|
# 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) ⇒ Object
53
54
55
56
57
58
|
# 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
|
34
35
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 34
def setup
end
|