Module: Adhearsion

Defined in:
lib/adhearsion.rb,
lib/adhearsion/call.rb,
lib/adhearsion/rayo.rb,
lib/adhearsion/calls.rb,
lib/adhearsion/error.rb,
lib/adhearsion/event.rb,
lib/adhearsion/events.rb,
lib/adhearsion/plugin.rb,
lib/adhearsion/router.rb,
lib/adhearsion/console.rb,
lib/adhearsion/logging.rb,
lib/adhearsion/process.rb,
lib/adhearsion/version.rb,
lib/adhearsion/rayo/ref.rb,
lib/adhearsion/uri_list.rb,
lib/adhearsion/event/end.rb,
lib/adhearsion/event/dtmf.rb,
lib/adhearsion/generators.rb,
lib/adhearsion/statistics.rb,
lib/adhearsion/translator.rb,
lib/adhearsion/event/offer.rb,
lib/adhearsion/has_headers.rb,
lib/adhearsion/http_server.rb,
lib/adhearsion/initializer.rb,
lib/adhearsion/rayo/client.rb,
lib/adhearsion/cli_commands.rb,
lib/adhearsion/event/joined.rb,
lib/adhearsion/rayo/command.rb,
lib/adhearsion/router/route.rb,
lib/adhearsion/configuration.rb,
lib/adhearsion/event/ringing.rb,
lib/adhearsion/outbound_call.rb,
lib/adhearsion/event/answered.rb,
lib/adhearsion/event/asterisk.rb,
lib/adhearsion/event/complete.rb,
lib/adhearsion/event/unjoined.rb,
lib/adhearsion/protocol_error.rb,
lib/adhearsion/rayo/component.rb,
lib/adhearsion/rayo/rayo_node.rb,
lib/adhearsion/call_controller.rb,
lib/adhearsion/linux_proc_name.rb,
lib/adhearsion/rayo/connection.rb,
lib/adhearsion/rayo/initializer.rb,
lib/adhearsion/plugin/collection.rb,
lib/adhearsion/rayo/command/dial.rb,
lib/adhearsion/rayo/command/join.rb,
lib/adhearsion/rayo/command/mute.rb,
lib/adhearsion/rayo/command_node.rb,
lib/adhearsion/script_ahn_loader.rb,
lib/adhearsion/event/asterisk/ami.rb,
lib/adhearsion/plugin/initializer.rb,
lib/adhearsion/rayo/command/accept.rb,
lib/adhearsion/rayo/command/answer.rb,
lib/adhearsion/rayo/command/hangup.rb,
lib/adhearsion/rayo/command/reject.rb,
lib/adhearsion/rayo/command/unjoin.rb,
lib/adhearsion/rayo/command/unmute.rb,
lib/adhearsion/rayo/component/stop.rb,
lib/adhearsion/translator/asterisk.rb,
lib/adhearsion/call_controller/dial.rb,
lib/adhearsion/event/active_speaker.rb,
lib/adhearsion/generators/generator.rb,
lib/adhearsion/rayo/component/input.rb,
lib/adhearsion/rayo/connection/xmpp.rb,
lib/adhearsion/router/evented_route.rb,
lib/adhearsion/call_controller/input.rb,
lib/adhearsion/rayo/command/redirect.rb,
lib/adhearsion/rayo/component/output.rb,
lib/adhearsion/rayo/component/prompt.rb,
lib/adhearsion/rayo/component/record.rb,
lib/adhearsion/call_controller/output.rb,
lib/adhearsion/call_controller/record.rb,
lib/adhearsion/event/started_speaking.rb,
lib/adhearsion/event/stopped_speaking.rb,
lib/adhearsion/router/openended_route.rb,
lib/adhearsion/rayo/component/asterisk.rb,
lib/adhearsion/rayo/component/send_fax.rb,
lib/adhearsion/rayo/disconnected_error.rb,
lib/adhearsion/cli_commands/ahn_command.rb,
lib/adhearsion/cli_commands/thor_errors.rb,
lib/adhearsion/rayo/connection/asterisk.rb,
lib/adhearsion/router/unaccepting_route.rb,
lib/adhearsion/translator/asterisk/call.rb,
lib/adhearsion/rayo/connection/connected.rb,
lib/adhearsion/event/input_timers_started.rb,
lib/adhearsion/rayo/component/receive_fax.rb,
lib/adhearsion/cli_commands/plugin_command.rb,
lib/adhearsion/rayo/component/asterisk/agi.rb,
lib/adhearsion/rayo/component/asterisk/ami.rb,
lib/adhearsion/translator/asterisk/agi_app.rb,
lib/adhearsion/translator/asterisk/channel.rb,
lib/adhearsion/call_controller/input/result.rb,
lib/adhearsion/generators/app/app_generator.rb,
lib/adhearsion/call_controller/output/player.rb,
lib/adhearsion/rayo/component/component_node.rb,
lib/adhearsion/translator/asterisk/component.rb,
lib/adhearsion/rayo/client/component_registry.rb,
lib/adhearsion/translator/asterisk/agi_command.rb,
lib/adhearsion/translator/asterisk/unimrcp_app.rb,
lib/adhearsion/call_controller/output/formatter.rb,
lib/adhearsion/call_controller/input/menu_builder.rb,
lib/adhearsion/generators/plugin/plugin_generator.rb,
lib/adhearsion/rayo/component/asterisk/ami/action.rb,
lib/adhearsion/rayo/connection/generic_connection.rb,
lib/adhearsion/call_controller/output/async_player.rb,
lib/adhearsion/rayo/component/asterisk/agi/command.rb,
lib/adhearsion/translator/asterisk/component/input.rb,
lib/adhearsion/call_controller/input/prompt_builder.rb,
lib/adhearsion/translator/asterisk/component/output.rb,
lib/adhearsion/translator/asterisk/component/record.rb,
lib/adhearsion/call_controller/output/abstract_player.rb,
lib/adhearsion/translator/asterisk/component/asterisk.rb,
lib/adhearsion/translator/asterisk/ami_error_converter.rb,
lib/adhearsion/call_controller/input/ask_grammar_builder.rb,
lib/adhearsion/translator/asterisk/component/mrcp_prompt.rb,
lib/adhearsion/generators/controller/controller_generator.rb,
lib/adhearsion/translator/asterisk/component/composed_prompt.rb,
lib/adhearsion/translator/asterisk/component/dtmf_recognizer.rb,
lib/adhearsion/translator/asterisk/component/input_component.rb,
lib/adhearsion/translator/asterisk/component/stop_by_redirect.rb,
lib/adhearsion/translator/asterisk/component/mrcp_recog_prompt.rb,
lib/adhearsion/translator/asterisk/component/mrcp_native_prompt.rb,
lib/adhearsion/translator/asterisk/component/asterisk/ami_action.rb,
lib/adhearsion/translator/asterisk/component/asterisk/agi_command.rb

Defined Under Namespace

Modules: CLI, Events, Generators, HasHeaders, LinuxProcName, Logging, Rayo, Safely, ScriptAhnLoader, Translator Classes: Call, CallController, Calls, Configuration, Console, Event, Initializer, OutboundCall, Plugin, Process, ProtocolError, Router, Statistics, URIList

Constant Summary collapse

Error =
Class.new StandardError
VERSION =
'3.0.0.rc1'
Application =
Adhearsion::Plugin

Class Method Summary collapse

Class Method Details

.active_callsObject



62
63
64
# File 'lib/adhearsion.rb', line 62

def active_calls
  @active_calls ||= Calls.new
end

.active_calls=(other) ⇒ Object



66
67
68
# File 'lib/adhearsion.rb', line 66

def active_calls=(other)
  @active_calls = other
end

.client_with_connection(type, options) ⇒ Adhearsion::Rayo::Client

Get a new client with a connection attached

Parameters:

  • type (Symbol)

    the connection type (eg :XMPP, :asterisk)

  • options (Hash)

    the options to pass to the connection (credentials, etc

Returns:



100
101
102
103
104
105
# File 'lib/adhearsion.rb', line 100

def client_with_connection(type, options)
  connection = Rayo::Connection.const_get(type == :xmpp ? 'XMPP' : type.to_s.classify).new options
  Rayo::Client.new :connection => connection
rescue NameError
  raise ArgumentError, "Connection type #{type.inspect} is not valid."
end

.config(&block) ⇒ Object



31
32
33
34
35
# File 'lib/adhearsion.rb', line 31

def config(&block)
  @config ||= Configuration.new(environment)
  block_given? and yield @config
  @config
end

.config=(config) ⇒ Object



50
51
52
# File 'lib/adhearsion.rb', line 50

def config=(config)
  @config = config
end

.deprecated(new_method) ⇒ Object



37
38
39
40
# File 'lib/adhearsion.rb', line 37

def deprecated(new_method)
  logger.info "#{caller[0]} - This method is deprecated, please use #{new_method}."
  logger.warn caller.join("\n")
end

.environmentObject



42
43
44
# File 'lib/adhearsion.rb', line 42

def environment
  @environment ||= (ENV['AHN_ENV'] || :development).to_sym
end

.environment=(other) ⇒ Object



46
47
48
# File 'lib/adhearsion.rb', line 46

def environment=(other)
  @environment = other ? other.to_sym : other
end

.execute_component(command, timeout = 60) ⇒ Object



107
108
109
110
111
112
# File 'lib/adhearsion.rb', line 107

def execute_component(command, timeout = 60)
  client.execute_command command, :async => true
  response = command.response timeout
  raise response if response.is_a? Exception
  command
end

.new_request_idObject



88
89
90
# File 'lib/adhearsion.rb', line 88

def new_request_id
  SecureRandom.uuid
end

.new_uuidObject



84
85
86
# File 'lib/adhearsion.rb', line 84

def new_uuid
  SecureRandom.uuid
end

.rootPathname

Returns the current application path

Returns:

  • (Pathname)

    The application path



27
28
29
# File 'lib/adhearsion.rb', line 27

def root
  Adhearsion.config[:core].root
end

.root=(path) ⇒ Object

Sets the application path @param The application path to set



19
20
21
# File 'lib/adhearsion.rb', line 19

def root=(path)
  Adhearsion.config[:core].root = path.nil? ? nil : File.expand_path(path)
end

.router(&block) ⇒ Object



54
55
56
# File 'lib/adhearsion.rb', line 54

def router(&block)
  @router ||= Router.new(&block || Proc.new {})
end

.router=(other) ⇒ Object



58
59
60
# File 'lib/adhearsion.rb', line 58

def router=(other)
  @router = other
end

.statisticsAdhearsion::Statistics

Returns a statistics aggregator object capable of producing stats dumps

Returns:



72
73
74
75
76
77
78
# File 'lib/adhearsion.rb', line 72

def statistics
  unless Celluloid::Actor[:statistics]
    Statistics.supervise_as :statistics
    Statistics.setup_event_handlers
  end
  Celluloid::Actor[:statistics]
end

.statusObject



80
81
82
# File 'lib/adhearsion.rb', line 80

def status
  Adhearsion::Process.state_name
end