Class: Signalwire::Relay::Calling::Connect
- Inherits:
-
Component
- Object
- Component
- Signalwire::Relay::Calling::Connect
show all
- Defined in:
- lib/signalwire/relay/calling/component/connect.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:, devices:, ringback: nil) ⇒ Connect
Returns a new instance of Connect.
5
6
7
8
9
|
# File 'lib/signalwire/relay/calling/component/connect.rb', line 5
def initialize(call:, devices:, ringback: nil)
super(call: call)
@devices = devices
@ringback = ringback
end
|
Instance Method Details
#broadcast_event(event) ⇒ Object
44
45
46
47
|
# File 'lib/signalwire/relay/calling/component/connect.rb', line 44
def broadcast_event(event)
@call.broadcast "connect_#{@state}".to_sym, event
@call.broadcast :connect_state_change, event
end
|
#inner_params ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/signalwire/relay/calling/component/connect.rb', line 19
def inner_params
params = {
node_id: @call.node_id,
call_id: @call.id,
devices: @devices
}
params[:ringback] = @ringback unless @ringback.nil?
params
end
|
#notification_handler(event) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/signalwire/relay/calling/component/connect.rb', line 30
def notification_handler(event)
@state = event.call_params[:connect_state]
@completed = @state != Relay::CallConnectState::CONNECTING
if @completed
@successful = @state == Relay::CallConnectState::CONNECTED
@event = event
end
broadcast_event(event)
check_for_waiting_events
end
|