Class: Signalwire::Relay::Calling::Hangup

Inherits:
Component
  • Object
show all
Defined in:
lib/signalwire/relay/calling/component/hangup.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?, #payload, #setup_handlers, #setup_waiting_events, #terminate, #unblock, #wait_for, #wait_on_blocker

Methods included from Logger

#level=, #logger, logger

Constructor Details

#initialize(call:, reason:) ⇒ Hangup

Returns a new instance of Hangup.



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

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

Instance Method Details

#event_typeObject



14
15
16
# File 'lib/signalwire/relay/calling/component/hangup.rb', line 14

def event_type
  Relay::CallNotification::STATE
end

#inner_paramsObject



18
19
20
21
22
23
24
# File 'lib/signalwire/relay/calling/component/hangup.rb', line 18

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

#methodObject



10
11
12
# File 'lib/signalwire/relay/calling/component/hangup.rb', line 10

def method
  Relay::ComponentMethod::HANGUP
end

#notification_handler(event) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/signalwire/relay/calling/component/hangup.rb', line 26

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

  @completed = @state == Relay::CallState::ENDED

  if @completed
    @successful = true
    @reason = end_reason
    @event = event
  end

  check_for_waiting_events
end