Class: Signalwire::Relay::Calling::SendDigits

Inherits:
ControlComponent show all
Defined in:
lib/signalwire/relay/calling/component/send_digits.rb

Instance Attribute Summary

Attributes inherited from Component

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

Instance Method Summary collapse

Methods inherited from ControlComponent

#control_id, #execute_subcommand, #setup_handlers

Methods inherited from Component

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

Methods included from Logger

#level=, #logger, logger

Constructor Details

#initialize(call:, digits:) ⇒ SendDigits

Returns a new instance of SendDigits.



3
4
5
6
# File 'lib/signalwire/relay/calling/component/send_digits.rb', line 3

def initialize(call:, digits:)
  super(call: call)
  @digits = digits
end

Instance Method Details

#broadcast_event(event) ⇒ Object



36
37
38
39
# File 'lib/signalwire/relay/calling/component/send_digits.rb', line 36

def broadcast_event(event)
  @call.broadcast "send_digits_#{@state}".to_sym, event
  @call.broadcast :send_digits_change, event
end

#event_typeObject



12
13
14
# File 'lib/signalwire/relay/calling/component/send_digits.rb', line 12

def event_type
  Relay::CallNotification::SEND_DIGITS
end

#inner_paramsObject



16
17
18
19
20
21
22
23
# File 'lib/signalwire/relay/calling/component/send_digits.rb', line 16

def inner_params
  {
    node_id: @call.node_id,
    call_id: @call.id,
    control_id: control_id,
    digits: @digits
  }
end

#methodObject



8
9
10
# File 'lib/signalwire/relay/calling/component/send_digits.rb', line 8

def method
  Relay::ComponentMethod::SEND_DIGITS
end

#notification_handler(event) ⇒ Object



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

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

  @completed = @state == Relay::CallSendDigitsState::FINISHED
  @successful = @completed
  @event = event

  broadcast_event(event)
  check_for_waiting_events
end

#stopObject



41
42
43
# File 'lib/signalwire/relay/calling/component/send_digits.rb', line 41

def stop
  logger.warn "SendDigits does not implement a stop action"
end