class Signalwire::Relay::Calling::Record

Attributes

duration[R]
size[R]
url[R]

Public Class Methods

new(call:, record:) click to toggle source
Calls superclass method
# File lib/signalwire/relay/calling/component/record.rb, line 6
def initialize(call:, record:)
  super(call: call)
  @record = record
end

Public Instance Methods

after_execute(execute_event) click to toggle source
# File lib/signalwire/relay/calling/component/record.rb, line 53
def after_execute(execute_event)
  @url = execute_event.dig(:params, :params, :params, :url) if execute_event
end
broadcast_event(event) click to toggle source
# File lib/signalwire/relay/calling/component/record.rb, line 48
def broadcast_event(event)
  @call.broadcast "record_#{@state}".to_sym, event
  @call.broadcast :record_state_change, event
end
event_type() click to toggle source
# File lib/signalwire/relay/calling/component/record.rb, line 15
def event_type
  Relay::CallNotification::RECORD
end
inner_params() click to toggle source
# File lib/signalwire/relay/calling/component/record.rb, line 19
def inner_params
  {
    node_id: @call.node_id,
    call_id: @call.id,
    control_id: control_id,
    record: @record
  }
end
method() click to toggle source
# File lib/signalwire/relay/calling/component/record.rb, line 11
def method
  Relay::ComponentMethod::RECORD
end
notification_handler(event) click to toggle source
# File lib/signalwire/relay/calling/component/record.rb, line 28
def notification_handler(event)
  @state = event.call_params[:state]
  url = event.call_params[:url]
  duration = event.call_params[:duration]
  size = event.call_params[:size]

  @completed = @state != Relay::CallRecordState::RECORDING

  if @completed
    @successful = @state == Relay::CallRecordState::FINISHED
    @url = url
    @duration = duration
    @size = size
    @event = event
  end

  broadcast_event(event)
  check_for_waiting_events
end