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, #execute_subcommand, #setup_handlers, #stop
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:, play:, volume: nil) ⇒ Play
Returns a new instance of Play.
5
6
7
8
9
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 5
def initialize(call:, play:, volume: nil)
super(call: call)
@play = play
@volume = volume
end
|
Instance Method Details
#broadcast_event(event) ⇒ Object
45
46
47
48
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 45
def broadcast_event(event)
@call.broadcast "play_#{@state}".to_sym, event
@call.broadcast :play_state_change, event
end
|
#inner_params ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 19
def inner_params
prm = {
node_id: @call.node_id,
call_id: @call.id,
control_id: control_id,
play: @play
}
prm[:volume] = @volume unless @volume.nil?
prm
end
|
#notification_handler(event) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 31
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
|
#volume(setting) ⇒ Object
58
59
60
|
# File 'lib/signalwire/relay/calling/component/play.rb', line 58
def volume(setting)
execute_subcommand '.volume', Signalwire::Relay::Calling::PlayVolumeResult, { volume: setting }
end
|