Class: Signalwire::Relay::Calling::ControlComponent

Inherits:
Component
  • Object
show all
Defined in:
lib/signalwire/relay/calling/control_component.rb

Direct Known Subclasses

BaseFax, Detect, Play, Prompt, Record, Tap

Instance Attribute Summary

Attributes inherited from Component

#blocker, #call, #completed, #event, #execute_result, #state, #successful

Instance Method Summary collapse

Methods inherited from Component

#check_for_waiting_events, #create_blocker, #event_type, #execute, #execute_params, #handle_execute_result, #initialize, #method, #notification_handler, #payload, #setup_waiting_events, #terminate, #unblock, #wait_for, #wait_on_blocker

Constructor Details

This class inherits a constructor from Signalwire::Relay::Calling::Component

Instance Method Details

#control_idObject



7
8
9
# File 'lib/signalwire/relay/calling/control_component.rb', line 7

def control_id
  @control_id ||= SecureRandom.uuid
end

#inner_paramsObject



11
12
13
14
15
16
17
18
# File 'lib/signalwire/relay/calling/control_component.rb', line 11

def inner_params
  {
    nodeid: @call.node_id,
    callid: @call.id,
    control_id: control_id,
    params: payload
  }
end

#setup_handlersObject



20
21
22
23
24
# File 'lib/signalwire/relay/calling/control_component.rb', line 20

def setup_handlers
  @call.on :event, event_type: event_type, control_id: control_id do |evt|
    notification_handler(evt)
  end
end

#stopObject



26
27
28
29
30
31
32
33
# File 'lib/signalwire/relay/calling/control_component.rb', line 26

def stop
  @call.relay_execute execute_params('.stop') do |event, outcome|
    if outcome == :failure
      terminate(event)
      return event
    end
  end
end