Class: Signalwire::Relay::Calling::Dial

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

Instance Attribute Summary

Attributes inherited from Component

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

Instance Method Summary collapse

Methods inherited from Component

#after_execute, #check_for_waiting_events, #create_blocker, #execute, #execute_params, #handle_execute_result, #has_blocker?, #initialize, #payload, #setup_handlers, #setup_waiting_events, #terminate, #unblock, #wait_for, #wait_on_blocker

Methods included from Logger

#level=, #logger, logger

Constructor Details

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

Instance Method Details

#event_typeObject



9
10
11
# File 'lib/signalwire/relay/calling/component/dial.rb', line 9

def event_type
  Relay::CallNotification::STATE
end

#inner_paramsObject



13
14
15
16
17
18
# File 'lib/signalwire/relay/calling/component/dial.rb', line 13

def inner_params
  {
    tag: @call.tag,
    device: @call.device
  }
end

#methodObject



5
6
7
# File 'lib/signalwire/relay/calling/component/dial.rb', line 5

def method
  Relay::ComponentMethod::DIAL
end

#notification_handler(event) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/signalwire/relay/calling/component/dial.rb', line 20

def notification_handler(event)
  @state = event.call_params[:call_state]

  ended_events = [Relay::CallState::ANSWERED, Relay::CallState::ENDING, Relay::CallState::ENDED]

  if ended_events.include?(@state)
    @completed = true
    @successful = true if @state == Relay::CallState::ANSWERED
    @event = event
  end

  check_for_waiting_events
end