Class: Adhearsion::Calls::Supervisor

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/adhearsion/calls.rb

Instance Method Summary collapse

Methods included from Celluloid

logger

Constructor Details

#initialize(collection) ⇒ Supervisor

Returns a new instance of Supervisor


90
91
92
# File 'lib/adhearsion/calls.rb', line 90

def initialize(collection)
  @collection = collection
end

Instance Method Details

#call_died(call, reason) ⇒ Object


94
95
96
97
98
99
100
101
102
103
# File 'lib/adhearsion/calls.rb', line 94

def call_died(call, reason)
  catching_standard_errors do
    call_id = @collection.key call
    @collection.remove_inactive_call call
    return unless reason
    Adhearsion::Events.trigger :exception, reason
    logger.error "Call #{call_id} terminated abnormally due to #{reason}. Forcing hangup."
    Adhearsion.client.execute_command Adhearsion::Rayo::Command::Hangup.new, :async => true, :call_id => call_id
  end
end