Class: Punchblock::Translator::Asterisk::Component::Component
- Inherits:
-
Object
- Object
- Punchblock::Translator::Asterisk::Component::Component
show all
- Defined in:
- lib/punchblock/translator/asterisk/component.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
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 = call.id if call
@id = Punchblock.new_uuid
@complete = false
setup
end
|
Instance Attribute Details
Returns the value of attribute call.
20
21
22
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 20
def call
@call
end
|
Returns the value of attribute call_id.
20
21
22
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 20
def call_id
@call_id
end
|
Returns the value of attribute id.
20
21
22
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 20
def id
@id
end
|
Instance Method Details
#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
52
53
54
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 52
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
|
# 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 reason: reason, recording: recording
send_event event
call.deregister_component id if call
end
|
#send_event(event) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 45
def send_event(event)
event.component_id = id
event.target_call_id = call_id
event.source_uri = id
translator.handle_pb_event event
end
|
30
31
|
# File 'lib/punchblock/translator/asterisk/component.rb', line 30
def setup
end
|