Module: Adhearsion

Defined in:
lib/adhearsion/version.rb,
lib/adhearsion.rb,
lib/adhearsion/cli.rb,
lib/adhearsion/logging.rb,
lib/adhearsion/voip/call.rb,
lib/adhearsion/initializer.rb,
lib/adhearsion/voip/commands.rb,
lib/adhearsion/events_support.rb,
lib/adhearsion/voip/constants.rb,
lib/adhearsion/voip/dial_plan.rb,
lib/adhearsion/initializer/drb.rb,
lib/adhearsion/xmpp/connection.rb,
lib/adhearsion/host_definitions.rb,
lib/adhearsion/initializer/ldap.rb,
lib/adhearsion/initializer/xmpp.rb,
lib/adhearsion/component_manager.rb,
lib/adhearsion/initializer/rails.rb,
lib/adhearsion/voip/call_routing.rb,
lib/adhearsion/voip/conveniences.rb,
lib/adhearsion/initializer/asterisk.rb,
lib/adhearsion/initializer/database.rb,
lib/adhearsion/voip/dsl/dialing_dsl.rb,
lib/adhearsion/voip/asterisk/commands.rb,
lib/adhearsion/voip/asterisk/agi_server.rb,
lib/adhearsion/voip/dsl/dialplan/parser.rb,
lib/adhearsion/initializer/configuration.rb,
lib/adhearsion/voip/dsl/numerical_string.rb,
lib/adhearsion/voip/freeswitch/oes_server.rb,
lib/adhearsion/voip/asterisk/super_manager.rb,
lib/adhearsion/foundation/custom_daemonizer.rb,
lib/adhearsion/voip/asterisk/config_manager.rb,
lib/adhearsion/voip/dsl/dialplan/dispatcher.rb,
lib/adhearsion/voip/freeswitch/event_handler.rb,
lib/adhearsion/voip/dsl/dialplan/thread_mixin.rb,
lib/adhearsion/voip/asterisk/manager_interface.rb,
lib/adhearsion/voip/menu_state_machine/matchers.rb,
lib/adhearsion/voip/menu_state_machine/menu_class.rb,
lib/adhearsion/voip/menu_state_machine/menu_builder.rb,
lib/adhearsion/voip/asterisk/special_dial_plan_managers.rb,
lib/adhearsion/voip/freeswitch/basic_connection_manager.rb,
lib/adhearsion/voip/menu_state_machine/calculated_match.rb,
lib/adhearsion/voip/asterisk/manager_interface/ami_lexer.rb,
lib/adhearsion/voip/freeswitch/inbound_connection_manager.rb,
lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb,
lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb,
lib/adhearsion/voip/dsl/dialplan/control_passing_exception.rb,
lib/adhearsion/voip/asterisk/manager_interface/ami_messages.rb,
lib/adhearsion/voip/asterisk/config_generators/voicemail.conf.rb,
lib/adhearsion/voip/dsl/dialing_dsl/dialing_dsl_monkey_patches.rb,
lib/adhearsion/voip/asterisk/config_generators/config_generator.rb,
lib/adhearsion/voip/freeswitch/freeswitch_dialplan_command_factory.rb

Overview

This is largely based on the Daemonize library by Travis Whitton and Judson Lester. grub.ath.cx/daemonize. I cleaned it up a bit to meet Adhearsion’s quality standards.

Defined Under Namespace

Modules: CLI, Components, CustomDaemonizer, Events, Logging, VERSION, VoIP, XMPP Classes: Call, Calls, Configuration, DialPlan, FailedExtensionCallException, Hangup, HostDefinition, HungupExtensionCallException, Initializer, MetaAgiCallException, PathString, PkgVersion, UselessCallException

Constant Summary collapse

AHN_INSTALL_DIR =

Sets up the Gem require path.

File.expand_path(File.dirname(__FILE__) + "/..")
AHN_CONFIG =
Configuration.new
IMPORTANT_THREADS =

This Array holds all the Threads whose life matters. Adhearsion will not exit until all of these have died.

[]

Class Method Summary collapse

Class Method Details

.active_callsObject



6
7
8
# File 'lib/adhearsion/voip/call.rb', line 6

def active_calls
  @calls ||= Calls.new
end

.receive_call_from(io, &block) ⇒ Object



10
11
12
13
# File 'lib/adhearsion/voip/call.rb', line 10

def receive_call_from(io, &block)
  active_calls << (call = Call.receive_from(io, &block))
  call
end

.remove_inactive_call(call) ⇒ Object



15
16
17
# File 'lib/adhearsion/voip/call.rb', line 15

def remove_inactive_call(call)
  active_calls.remove_inactive_call(call)
end

.shutdown!Object

Shuts down the framework.



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

def shutdown!
  if self.status == :stopping
    # This is the second shutdown request we've received while attempting
    # to shut down gracefully.  At this point, let's pull the plug...
    ahn_log.warning "Shutting down immediately at #{Time.now}"
    exit
  end
  ahn_log "Shutting down gracefully at #{Time.now}."
  self.status = :stopping
  Events.trigger_immediately :shutdown
  Events.stop!
  exit
end