Class: Punchblock::Translator::Asterisk::Component::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/punchblock/translator/asterisk/component.rb

Direct Known Subclasses

Asterisk::AGICommand, Asterisk::AMIAction, ComposedPrompt, Input, MRCPNativePrompt, MRCPPrompt, Output, Record

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Component) initialize(component_node, call = nil)



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

- (Object) call (readonly)

Returns the value of attribute call



20
21
22
# File 'lib/punchblock/translator/asterisk/component.rb', line 20

def call
  @call
end

- (Object) call_id (readonly)

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

- (Object) id (readonly)

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

- (Object) call_ended



56
57
58
# File 'lib/punchblock/translator/asterisk/component.rb', line 56

def call_ended
  send_complete_event Punchblock::Event::Complete::Hangup.new
end

- (Object) execute_command(command)



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

- (Object) logger_id



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

- (Object) send_complete_event(reason, recording = nil)



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

- (Object) send_event(event)



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

- (Object) setup



30
31
# File 'lib/punchblock/translator/asterisk/component.rb', line 30

def setup
end