Class: Signalwire::Relay::Calling::BaseFax

Inherits:
ControlComponent show all
Defined in:
lib/signalwire/relay/calling/component/base_fax.rb

Direct Known Subclasses

FaxReceive, FaxSend

Instance Attribute Summary collapse

Attributes inherited from Component

#blocker, #call, #completed, #event, #execute_result, #state, #successful

Instance Method Summary collapse

Methods inherited from ControlComponent

#control_id, #execute_subcommand, #inner_params, #setup_handlers, #stop

Methods inherited from Component

#after_execute, #check_for_waiting_events, #create_blocker, #execute, #execute_params, #handle_execute_result, #has_blocker?, #initialize, #inner_params, #method, #payload, #setup_handlers, #setup_waiting_events, #terminate, #unblock, #wait_for, #wait_on_blocker

Methods included from Logger

#level=, #logger, logger

Constructor Details

This class inherits a constructor from Signalwire::Relay::Calling::Component

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



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

def direction
  @direction
end

#documentObject (readonly)

Returns the value of attribute document.



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

def document
  @document
end

#identityObject (readonly)

Returns the value of attribute identity.



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

def identity
  @identity
end

#pagesObject (readonly)

Returns the value of attribute pages.



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

def pages
  @pages
end

#remote_identityObject (readonly)

Returns the value of attribute remote_identity.



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

def remote_identity
  @remote_identity
end

Instance Method Details

#broadcast_event(event) ⇒ Object



35
36
37
38
# File 'lib/signalwire/relay/calling/component/base_fax.rb', line 35

def broadcast_event(event)
  @call.broadcast "fax_#{@state}".to_sym, event
  @call.broadcast :fax_state_change, event
end

#event_typeObject



7
8
9
# File 'lib/signalwire/relay/calling/component/base_fax.rb', line 7

def event_type
  Relay::CallNotification::FAX
end

#notification_handler(event) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/signalwire/relay/calling/component/base_fax.rb', line 11

def notification_handler(event)
  fax_state = event.call_params[:fax]
  fax_params = fax_state[:params]
  @state = fax_state[:type]

  @completed = @state != Relay::CallFaxState::PAGE

  if @completed
    if fax_params[:success]
      @successful = true
      @direction = fax_params[:direction]
      @identity = fax_params[:identity]
      @remote_identity = fax_params[:remote_identity]
      @document = fax_params[:document]
      @pages = fax_params[:pages]
    end

    @event = event
  end

  broadcast_event(event)
  check_for_waiting_events
end