Class: Signalwire::Relay::Calling::Play
Instance Attribute Summary
Attributes inherited from Component
#blocker, #call, #completed, #event, #execute_result, #state, #successful
Instance Method Summary
collapse
#control_id, #setup_handlers, #stop
Methods inherited from Component
#check_for_waiting_events, #create_blocker, #execute, #execute_params, #handle_execute_result, #payload, #setup_handlers, #setup_waiting_events, #terminate, #unblock, #wait_for, #wait_on_blocker
Constructor Details
#initialize(call:, play:) ⇒ Play
Returns a new instance of Play.
5
6
7
8
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 5
def initialize(call:, play:)
super(call: call)
@play = play
end
|
Instance Method Details
#broadcast_event(event) ⇒ Object
41
42
43
44
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 41
def broadcast_event(event)
@call.broadcast "play_#{@state}".to_sym, event
@call.broadcast :play_state_change, event
end
|
#event_type ⇒ Object
14
15
16
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 14
def event_type
Relay::CallNotification::PLAY
end
|
#inner_params ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 18
def inner_params
{
node_id: @call.node_id,
call_id: @call.id,
control_id: control_id,
play: @play
}
end
|
#method ⇒ Object
10
11
12
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 10
def method
Relay::ComponentMethod::PLAY
end
|
#notification_handler(event) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 27
def notification_handler(event)
@state = event.call_params[:state]
@completed = @state != Relay::CallPlayState::PLAYING
if @completed
@successful = true if @state == Relay::CallPlayState::FINISHED
@event = event
end
broadcast_event(event)
check_for_waiting_events
end
|