Class: Punchblock::Translator::Freeswitch::Component::Component
- Inherits:
-
Object
- Object
- Punchblock::Translator::Freeswitch::Component::Component
show all
- Includes:
- Celluloid, HasGuardedHandlers, DeadActorSafety
- Defined in:
- lib/punchblock/translator/freeswitch/component.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#safe_from_dead_actors
Constructor Details
#initialize(component_node, call = nil) ⇒ Component
Returns a new instance of Component.
23
24
25
26
27
28
29
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 23
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.
21
22
23
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 21
def call
@call
end
|
Returns the value of attribute call_id.
21
22
23
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 21
def call_id
@call_id
end
|
Returns the value of attribute id.
21
22
23
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 21
def id
@id
end
|
Instance Method Details
#application(appname, options = nil) ⇒ Object
67
68
69
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 67
def application(appname, options = nil)
call.application appname, "%[punchblock_component_id=#{id}]#{options}"
end
|
#execute_command(command) ⇒ Object
34
35
36
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 34
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
38
39
40
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 38
def handle_es_event(event)
trigger_handler :es, event
end
|
#logger_id ⇒ Object
59
60
61
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 59
def logger_id
"#{self.class}: #{call_id ? "Call ID: #{call_id}, Component ID: #{id}" : id}"
end
|
#send_complete_event(reason, recording = nil) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 42
def send_complete_event(reason, recording = nil)
return if @complete
@complete = true
event = Punchblock::Event::Complete.new.tap do |c|
c.reason = reason
c << recording if recording
end
send_event event
current_actor.terminate!
end
|
#send_event(event) ⇒ Object
53
54
55
56
57
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 53
def send_event(event)
event.component_id = id
event.target_call_id = call_id
safe_from_dead_actors { translator.handle_pb_event event }
end
|
31
32
|
# File 'lib/punchblock/translator/freeswitch/component.rb', line 31
def setup
end
|