Class: Punchblock::Translator::Asterisk::Component::Component
- Inherits:
-
Object
- Object
- Punchblock::Translator::Asterisk::Component::Component
show all
- Includes:
- Celluloid, DeadActorSafety
- Defined in:
- lib/punchblock/translator/asterisk/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.
21
22
23
24
25
26
27
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 21
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.
19
20
21
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 19
def call
@call
end
|
Returns the value of attribute call_id.
19
20
21
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 19
def call_id
@call_id
end
|
Returns the value of attribute id.
19
20
21
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 19
def id
@id
end
|
Instance Method Details
#execute_command(command) ⇒ Object
32
33
34
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 32
def execute_command(command)
command.response = ProtocolError.new.setup 'command-not-acceptable', "Did not understand command for component #{id}", call_id, id
end
|
#logger_id ⇒ Object
53
54
55
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 53
def logger_id
"#{self.class}: #{call_id ? "Call ID: #{call_id}, Component ID: #{id}" : id}"
end
|
#send_complete_event(reason, recording = nil, should_terminate = true) ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 36
def send_complete_event(reason, recording = nil, should_terminate = true)
return if @complete
@complete = true
event = Punchblock::Event::Complete.new.tap do |c|
c.reason = reason
c << recording if recording
end
send_event event
terminate if should_terminate
end
|
#send_event(event) ⇒ Object
47
48
49
50
51
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 47
def send_event(event)
event.component_id = id
event.target_call_id = call_id
safe_from_dead_actors { translator.handle_pb_event event }
end
|
29
30
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 29
def setup
end
|