Class: Punchblock::Translator::Asterisk::Component::Component
- Includes:
- Celluloid, DeadActorSafety
- Defined in:
- lib/punchblock/translator/asterisk/component.rb
Direct Known Subclasses
Asterisk::AGICommand, Asterisk::AMIAction, Input, Output, Record
Instance Attribute Summary collapse
-
#call ⇒ Object
readonly
Returns the value of attribute call.
-
#call_id ⇒ Object
readonly
Returns the value of attribute call_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#internal ⇒ Object
Returns the value of attribute internal.
Instance Method Summary collapse
- #call_ended ⇒ Object
- #execute_command(command) ⇒ Object
-
#initialize(component_node, call = nil) ⇒ Component
constructor
A new instance of Component.
- #logger_id ⇒ Object
- #send_complete_event(reason, recording = nil) ⇒ Object
- #send_event(event) ⇒ Object
- #setup ⇒ Object
Methods included from DeadActorSafety
Constructor Details
#initialize(component_node, call = nil) ⇒ Component
Returns a new instance of Component.
22 23 24 25 26 27 28 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 22 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
#call ⇒ Object (readonly)
Returns the value of attribute call.
19 20 21 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 19 def call @call end |
#call_id ⇒ Object (readonly)
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 |
#id ⇒ Object (readonly)
Returns the value of attribute id.
19 20 21 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 19 def id @id end |
#internal ⇒ Object
Returns the value of attribute internal.
20 21 22 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 20 def internal @internal end |
Instance Method Details
#call_ended ⇒ Object
62 63 64 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 62 def call_ended send_complete_event Punchblock::Event::Complete::Hangup.new end |
#execute_command(command) ⇒ Object
33 34 35 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 33 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
58 59 60 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 58 def logger_id "#{self.class}: #{call_id ? "Call ID: #{call_id}, Component ID: #{id}" : id}" end |
#send_complete_event(reason, recording = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 37 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 terminate end |
#send_event(event) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 48 def send_event(event) event.component_id = id event.target_call_id = call_id if internal @component_node.add_event event else safe_from_dead_actors { translator.handle_pb_event event } end end |
#setup ⇒ Object
30 31 |
# File 'lib/punchblock/translator/asterisk/component.rb', line 30 def setup end |