Class: Adhearsion::Initializer::AsteriskInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/adhearsion/initializer/asterisk.rb

Class Method Summary collapse

Class Method Details

.startObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/adhearsion/initializer/asterisk.rb', line 10

def start
  self.config     = AHN_CONFIG.asterisk
  self.agi_server = initialize_agi
  self.ami_client = VoIP::Asterisk.manager_interface = initialize_ami if config.ami_enabled?
  join_server_thread_after_initialized

  # Make sure we stop everything when we shutdown
  Events.register_callback(:shutdown) do
    ahn_log.info "Shutting down with #{Adhearsion.active_calls.size} active calls"
    self.stop
  end
end

.stopObject



23
24
25
26
# File 'lib/adhearsion/initializer/asterisk.rb', line 23

def stop
  agi_server.graceful_shutdown
  ami_client.disconnect! if ami_client
end