adhearsion 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +4 -1
- data/lib/adhearsion/initializer.rb +1 -1
- data/lib/adhearsion/version.rb +1 -1
- data/lib/adhearsion/voip/asterisk/commands.rb +135 -133
- data/lib/adhearsion/voip/asterisk/manager_interface.rb +39 -51
- data/spec/voip/asterisk/commands_spec.rb +3 -3
- metadata +383 -410
data/CHANGELOG
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
1.0.3
|
2
|
+
- Fix the play() command regression when passing an array of strings. This was breaking the SimonGame
|
3
|
+
- Deprecate ManagerInterface#send_action_asynchronously
|
4
|
+
|
1
5
|
1.0.2
|
2
6
|
- Fix rcov Rake task
|
3
7
|
- Add Ben Langfeld as an author (Thanks, Ben!)
|
4
8
|
- Add "rake" as a runtime dependency
|
5
9
|
- Remove usage of BEGIN blocks (for Rubinius; CS)
|
6
|
-
- Improve component testing generators
|
7
10
|
|
8
11
|
1.0.1
|
9
12
|
NOTE for Ruby 1.9 users: The behavior of Ruby 1.9 and case statements has changed
|
@@ -91,7 +91,7 @@ module Adhearsion
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def ahn_root=(path)
|
94
|
-
if Object.constants.include?(
|
94
|
+
if Object.constants.map(&:to_sym).include?(:AHN_ROOT)
|
95
95
|
Object.const_get(:AHN_ROOT).base_path = File.expand_path(path)
|
96
96
|
else
|
97
97
|
Object.const_set(:AHN_ROOT, PathString.new(File.expand_path(path)))
|
data/lib/adhearsion/version.rb
CHANGED
@@ -175,7 +175,7 @@ module Adhearsion
|
|
175
175
|
# Fixnums (e.g. 1000), Strings which are valid Fixnums (e.g "123"), and direct sound files. When playing
|
176
176
|
# numbers, Adhearsion assumes you're saying the number, not the digits. For example, play("100")
|
177
177
|
# is pronounced as "one hundred" instead of "one zero zero". To specify how the Date/Time objects are said
|
178
|
-
# pass in as an array with the first parameter as the Date/Time/DateTime object along with a hash with the
|
178
|
+
# pass in as an array with the first parameter as the Date/Time/DateTime object along with a hash with the
|
179
179
|
# additional options. See play_time for more information.
|
180
180
|
#
|
181
181
|
# Note: it is not necessary to supply a sound file extension; Asterisk will try to find a sound
|
@@ -196,8 +196,10 @@ module Adhearsion
|
|
196
196
|
# play "you-sound-cute", "what-are-you-wearing"
|
197
197
|
#
|
198
198
|
def play(*arguments)
|
199
|
-
arguments
|
200
|
-
|
199
|
+
unless play_time(arguments)
|
200
|
+
arguments.flatten.each do |argument|
|
201
|
+
play_numeric(argument) || play_string(argument)
|
202
|
+
end
|
201
203
|
end
|
202
204
|
end
|
203
205
|
|
@@ -347,14 +349,14 @@ module Adhearsion
|
|
347
349
|
# It's important to understand the differences between these and how they affect the overall outcome:
|
348
350
|
#
|
349
351
|
# |---------------|-------------------|------------------------------------------------------|
|
350
|
-
# | exact matches |
|
352
|
+
# | exact matches | potential matches | result |
|
351
353
|
# |---------------|-------------------|------------------------------------------------------|
|
352
|
-
# | 0
|
353
|
-
# | 1
|
354
|
-
# | 0
|
355
|
-
# | >1
|
356
|
-
# | 1
|
357
|
-
# | >1
|
354
|
+
# | 0 | 0 | Fail and start over |
|
355
|
+
# | 1 | 0 | Match found! |
|
356
|
+
# | 0 | >0 | Get another digit |
|
357
|
+
# | >1 | 0 | Go with the first exact match |
|
358
|
+
# | 1 | >0 | Get another digit. If timeout, use exact match |
|
359
|
+
# | >1 | >0 | Get another digit. If timeout, use first exact match |
|
358
360
|
# |---------------|-------------------|------------------------------------------------------|
|
359
361
|
#
|
360
362
|
# == Database integration
|
@@ -450,30 +452,30 @@ module Adhearsion
|
|
450
452
|
# 1. The number of digits you specify as the first argument is collected
|
451
453
|
# 2. The timeout you specify with the :timeout option elapses.
|
452
454
|
# 3. The "#" key (or the key you specify with :accept_key) is pressed
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
455
|
+
#
|
456
|
+
# Usage examples
|
457
|
+
#
|
458
|
+
# input # Receives digits until the caller presses the "#" key
|
459
|
+
# input 3 # Receives three digits. Can be 0-9, * or #
|
460
|
+
# input 5, :accept_key => "*" # Receive at most 5 digits, stopping if '*' is pressed
|
461
|
+
# input 1, :timeout => 1.minute # Receive a single digit, returning an empty
|
462
|
+
# string if the timeout is encountered
|
463
|
+
# input 9, :timeout => 7, :accept_key => "0" # Receives nine digits, returning
|
464
|
+
# # when the timeout is encountered
|
465
|
+
# # or when the "0" key is pressed.
|
466
|
+
# input 3, :play => "you-sound-cute"
|
467
|
+
# input :play => ["if-this-is-correct-press", 1, "otherwise-press", 2]
|
468
|
+
#
|
469
|
+
# When specifying files to play, the playback of the sequence of files will stop
|
470
|
+
# immediately when the user presses the first digit.
|
471
|
+
#
|
472
|
+
# The :timeout option works like a digit timeout, therefore each digit pressed
|
473
|
+
# causes the timer to reset. This is a much more user-friendly approach than an
|
472
474
|
# absolute timeout.
|
473
|
-
|
475
|
+
#
|
474
476
|
# Note that when the digit limit is not specified the :accept_key becomes "#".
|
475
477
|
# Otherwise there would be no way to end the collection of digits. You can
|
476
|
-
|
478
|
+
# obviously override this by passing in a new key with :accept_key.
|
477
479
|
def input(*args)
|
478
480
|
options = args.last.kind_of?(Hash) ? args.pop : {}
|
479
481
|
number_of_digits = args.shift
|
@@ -510,7 +512,7 @@ module Adhearsion
|
|
510
512
|
end
|
511
513
|
key = wait_for_digit(timeout || -1)
|
512
514
|
end
|
513
|
-
|
515
|
+
end
|
514
516
|
|
515
517
|
# Jumps to a context. An alternative to DialplanContextProc#+@. When jumping to a context, it will *not* resume executing
|
516
518
|
# the former context when the jumped-to context has finished executing. Make sure you don't have any
|
@@ -545,36 +547,36 @@ module Adhearsion
|
|
545
547
|
raise Adhearsion::VoIP::DSL::Dialplan::ControlPassingException.new(context)
|
546
548
|
end
|
547
549
|
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
550
|
+
# Place a call in a queue to be answered by a registered agent. You must then call join!()
|
551
|
+
#
|
552
|
+
# @param [String] queue_name the queue name to place the caller in
|
553
|
+
# @return [Adhearsion::VoIP::Asterisk::Commands::QueueProxy] a queue proxy object
|
552
554
|
#
|
553
555
|
# @see http://www.voip-info.org/wiki-Asterisk+cmd+Queue Full information on the Asterisk Queue
|
554
556
|
# @see Adhearsion::VoIP::Asterisk::Commands::QueueProxy#join! join!() for further details
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
557
|
+
def queue(queue_name)
|
558
|
+
queue_name = queue_name.to_s
|
559
|
+
|
560
|
+
@queue_proxy_hash_lock = Mutex.new unless defined? @queue_proxy_hash_lock
|
561
|
+
@queue_proxy_hash_lock.synchronize do
|
562
|
+
@queue_proxy_hash ||= {}
|
563
|
+
if @queue_proxy_hash.has_key? queue_name
|
564
|
+
return @queue_proxy_hash[queue_name]
|
565
|
+
else
|
566
|
+
proxy = @queue_proxy_hash[queue_name] = QueueProxy.new(queue_name, self)
|
567
|
+
return proxy
|
568
|
+
end
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
# Get the status of the last dial(). Possible dial statuses include :answer,
|
571
573
|
# :busy, :no_answer, :cancelled, :congested, and :channel_unavailable.
|
572
574
|
# If :cancel is returned, the caller hung up before the callee picked up.
|
573
575
|
# If :congestion is returned, the dialed extension probably doesn't exist.
|
574
576
|
# If :channel_unavailable, the callee phone may not be registered.
|
575
|
-
|
576
|
-
|
577
|
-
|
577
|
+
def last_dial_status
|
578
|
+
DIAL_STATUSES[get_dial_status]
|
579
|
+
end
|
578
580
|
|
579
581
|
# @return [Boolean] true if your last call to dial() finished with the ANSWER state,
|
580
582
|
# as reported by Asterisk. false otherwise
|
@@ -663,49 +665,49 @@ module Adhearsion
|
|
663
665
|
# @param [String] variable_name
|
664
666
|
#
|
665
667
|
# @see: http://www.voip-info.org/wiki/view/get+variable Asterisk Get Variable
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
668
|
+
def get_variable(variable_name)
|
669
|
+
result = response("GET VARIABLE", variable_name)
|
670
|
+
case result
|
671
|
+
when "200 result=0"
|
672
|
+
return nil
|
673
|
+
when /^200 result=1 \((.*)\)$/
|
674
|
+
return $LAST_PAREN_MATCH
|
675
|
+
end
|
676
|
+
end
|
677
|
+
|
678
|
+
# Pass information back to the asterisk dial plan.
|
679
|
+
#
|
680
|
+
# Keep in mind that the variables are not global variables. These variables only exist for the channel
|
681
|
+
# related to the call that is being serviced by the particular instance of your adhearsion application.
|
682
|
+
# You will not be able to pass information back to the asterisk dialplan for other instances of your adhearsion
|
683
|
+
# application to share. Once the channel is "hungup" then the variables are cleared and their information is gone.
|
684
|
+
#
|
685
|
+
# @param [String] variable_name
|
686
|
+
# @param [String] value
|
687
|
+
#
|
688
|
+
# @see http://www.voip-info.org/wiki/view/set+variable Asterisk Set Variable
|
689
|
+
def set_variable(variable_name, value)
|
690
|
+
response("SET VARIABLE", variable_name, value) == "200 result=1"
|
691
|
+
end
|
692
|
+
|
691
693
|
# Issue the command to add a custom SIP header to the current call channel
|
692
694
|
# example use: sip_add_header("x-ahn-test", "rubyrox")
|
693
695
|
#
|
694
696
|
# @param[String] the name of the SIP header
|
695
697
|
# @param[String] the value of the SIP header
|
696
|
-
#
|
698
|
+
#
|
697
699
|
# @return [String] the Asterisk response
|
698
700
|
#
|
699
701
|
# @see http://www.voip-info.org/wiki/index.php?page=Asterisk+cmd+SIPAddHeader Asterisk SIPAddHeader
|
700
702
|
def sip_add_header(header, value)
|
701
703
|
execute("SIPAddHeader", "#{header}: #{value}") == "200 result=1"
|
702
704
|
end
|
703
|
-
|
705
|
+
|
704
706
|
# Issue the command to fetch a SIP header from the current call channel
|
705
707
|
# example use: sip_get_header("x-ahn-test")
|
706
708
|
#
|
707
709
|
# @param[String] the name of the SIP header to get
|
708
|
-
#
|
710
|
+
#
|
709
711
|
# @return [String] the Asterisk response
|
710
712
|
#
|
711
713
|
# @see http://www.voip-info.org/wiki/index.php?page=Asterisk+cmd+SIPGetHeader Asterisk SIPGetHeader
|
@@ -713,32 +715,32 @@ module Adhearsion
|
|
713
715
|
get_variable("SIP_HEADER(#{header})")
|
714
716
|
end
|
715
717
|
alias :sip_header :sip_get_header
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
718
|
+
|
719
|
+
# Allows you to either set or get a channel variable from Asterisk.
|
720
|
+
# The method takes a hash key/value pair if you would like to set a variable
|
721
|
+
# Or a single string with the variable to get from Asterisk
|
722
|
+
def variable(*args)
|
723
|
+
if args.last.kind_of? Hash
|
724
|
+
assignments = args.pop
|
725
|
+
raise ArgumentError, "Can't mix variable setting and fetching!" if args.any?
|
726
|
+
assignments.each_pair do |key, value|
|
727
|
+
set_variable(key, value)
|
728
|
+
end
|
729
|
+
else
|
730
|
+
if args.size == 1
|
731
|
+
get_variable args.first
|
732
|
+
else
|
733
|
+
args.map { |var| get_variable(var) }
|
734
|
+
end
|
735
|
+
end
|
736
|
+
end
|
737
|
+
|
738
|
+
# Send a caller to a voicemail box to leave a message.
|
739
|
+
#
|
740
|
+
# The method takes the mailbox_number of the user to leave a message for and a
|
741
|
+
# greeting_option that will determine which message gets played to the caller.
|
742
|
+
#
|
743
|
+
# @see http://www.voip-info.org/tiki-index.php?page=Asterisk+cmd+VoiceMail Asterisk Voicemail
|
742
744
|
def voicemail(*args)
|
743
745
|
options_hash = args.last.kind_of?(Hash) ? args.pop : {}
|
744
746
|
mailbox_number = args.shift
|
@@ -884,20 +886,20 @@ module Adhearsion
|
|
884
886
|
# end
|
885
887
|
|
886
888
|
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
889
|
+
# Speaks the digits given as an argument. For example, "123" is spoken as "one two three".
|
890
|
+
#
|
891
|
+
# @param [String] digits
|
892
|
+
def say_digits(digits)
|
893
|
+
execute "saydigits", validate_digits(digits)
|
894
|
+
end
|
895
|
+
|
896
|
+
# Get the number of seconds the given block takes to execute. This
|
897
|
+
# is particularly useful in dialplans for tracking billable time. Note that
|
898
|
+
# if the call is hung up during the block, you will need to rescue the
|
899
|
+
# exception if you have some mission-critical logic after it with which
|
900
|
+
# you're recording this return-value.
|
901
|
+
#
|
902
|
+
# @return [Float] number of seconds taken for block to execute
|
901
903
|
def duration_of
|
902
904
|
start_time = Time.now
|
903
905
|
yield
|
@@ -918,7 +920,7 @@ module Adhearsion
|
|
918
920
|
end
|
919
921
|
|
920
922
|
##
|
921
|
-
# Executes the SayPhonetic command. This command will read the text passed in
|
923
|
+
# Executes the SayPhonetic command. This command will read the text passed in
|
922
924
|
# out load using the NATO phonetic alphabet.
|
923
925
|
#
|
924
926
|
# @param [String] Passed in as the text to read aloud
|
@@ -956,21 +958,21 @@ module Adhearsion
|
|
956
958
|
argument, options = args.flatten
|
957
959
|
options ||= {}
|
958
960
|
|
961
|
+
return false unless options.is_a? Hash
|
962
|
+
|
959
963
|
timezone = options.delete(:timezone) || ''
|
960
964
|
format = options.delete(:format) || ''
|
961
|
-
epoch = case argument
|
962
|
-
when
|
963
|
-
|
964
|
-
when
|
965
|
+
epoch = case argument
|
966
|
+
when Time || DateTime
|
967
|
+
argument.to_i
|
968
|
+
when Date
|
965
969
|
format = 'BdY' unless format.present?
|
966
970
|
argument.to_time.to_i
|
967
|
-
else
|
968
|
-
nil
|
969
971
|
end
|
970
972
|
|
971
973
|
return false if epoch.nil?
|
972
974
|
|
973
|
-
execute
|
975
|
+
execute :sayunixtime, epoch, timezone, format
|
974
976
|
end
|
975
977
|
|
976
978
|
protected
|
@@ -1251,7 +1253,7 @@ module Adhearsion
|
|
1251
1253
|
# queue('sales').join! :allow_transfer => :agent, :timeout => 30.seconds,
|
1252
1254
|
def join!(options={})
|
1253
1255
|
environment.execute("queue", name, *self.class.format_join_hash_key_arguments(options))
|
1254
|
-
|
1256
|
+
normalize_queue_status_variable environment.variable("QUEUESTATUS")
|
1255
1257
|
end
|
1256
1258
|
|
1257
1259
|
# Get the agents associated with a queue
|
@@ -1310,7 +1312,7 @@ module Adhearsion
|
|
1310
1312
|
# LEAVEUNAVAIL => :leaveunavail
|
1311
1313
|
# CONTINUE => :continue
|
1312
1314
|
#
|
1313
|
-
# If the QUEUESTATUS variable is not set the call was successfully connected,
|
1315
|
+
# If the QUEUESTATUS variable is not set the call was successfully connected,
|
1314
1316
|
# and Adhearsion will return :completed.
|
1315
1317
|
#
|
1316
1318
|
# @param [String] QUEUESTATUS variable from Asterisk
|
@@ -285,16 +285,20 @@ module Adhearsion
|
|
285
285
|
# @param [String, Symbol] action_name The name of the action (e.g. Originate)
|
286
286
|
# @param [Hash] headers Other key/value pairs to send in this action. Note: don't provide an ActionID
|
287
287
|
# @return [FutureResource] Call resource() on this object if you wish to access the response (optional). Note: if the response has not come in yet, your Thread will wait until it does.
|
288
|
+
# @deprecated Async AMI is deprecated
|
288
289
|
#
|
289
290
|
def send_action_asynchronously(action_name, headers={})
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
291
|
+
ahn_log.ami.deprecation.warn <<WARN
|
292
|
+
\n
|
293
|
+
Asterisk only supports one outstanding action ID at a time, making the
|
294
|
+
asynchronous AMI interface dangerous to use. This interface is now
|
295
|
+
deprecated and will disappear in future versions of Adhearsion. If you need
|
296
|
+
to do background processing while Asterisk processes a long-running action
|
297
|
+
(such as a synchronous Originate) then you will need to handle this manually
|
298
|
+
with Ruby threads. Note that Originate specifically has an :Async header
|
299
|
+
which tells Asterisk to process the Originate event asynchronously.
|
300
|
+
WARN
|
301
|
+
_send_action_asynchronously(action_name, headers)
|
298
302
|
end
|
299
303
|
|
300
304
|
##
|
@@ -307,35 +311,20 @@ module Adhearsion
|
|
307
311
|
# @return [ManagerInterfaceResponse, ImmediateResponse] Contains the response from Asterisk and all headers
|
308
312
|
#
|
309
313
|
def send_action_synchronously(*args)
|
310
|
-
|
314
|
+
_send_action_asynchronously(*args).response.tap do |response|
|
311
315
|
raise response if response.kind_of?(ManagerInterfaceError)
|
312
316
|
end
|
313
317
|
end
|
314
318
|
|
315
319
|
alias send_action send_action_synchronously
|
316
320
|
|
317
|
-
|
318
|
-
####### #######
|
319
|
-
########### ###########
|
320
|
-
################# SOON-DEPRECATED COMMANDS #################
|
321
|
-
########### ###########
|
322
|
-
####### #######
|
323
|
-
|
324
321
|
# ping sends an action to the Asterisk Manager Interface that returns a pong
|
325
322
|
# more details here: http://www.voip-info.org/wiki/index.php?page=Asterisk+Manager+API+Action+Ping
|
326
323
|
def ping
|
327
|
-
#deprecation_warning
|
328
324
|
send_action "Ping"
|
329
325
|
true
|
330
326
|
end
|
331
327
|
|
332
|
-
def deprecation_warning
|
333
|
-
ahn_log.ami.deprecation.warn "The implementation of the ping, originate, introduce, hangup, call_into_context " +
|
334
|
-
"and call_and_exec methods will soon be moved from this class to SuperManager. At the moment, the " +
|
335
|
-
"SuperManager abstractions are not completed. Don't worry. The migration to SuperManager will be very easy."+
|
336
|
-
" See http://docs.adhearsion.com/AMI for more information."
|
337
|
-
end
|
338
|
-
|
339
328
|
# The originate method launches a call to Asterisk, full details here:
|
340
329
|
# http://www.voip-info.org/tiki-index.php?page=Asterisk+Manager+API+Action+Originate
|
341
330
|
# Takes these arguments as a hash:
|
@@ -360,7 +349,6 @@ module Adhearsion
|
|
360
349
|
# :exten => 's',
|
361
350
|
# :priority => '1' }
|
362
351
|
def originate(options={})
|
363
|
-
#deprecation_warning
|
364
352
|
options = options.clone
|
365
353
|
options[:callerid] = options.delete :caller_id if options.has_key? :caller_id
|
366
354
|
options[:exten] = options.delete :extension if options.has_key? :extension
|
@@ -382,7 +370,6 @@ module Adhearsion
|
|
382
370
|
# TODO: Provide an example when this works.
|
383
371
|
#
|
384
372
|
def introduce(caller, callee, opts={})
|
385
|
-
#deprecation_warning
|
386
373
|
dial_args = callee
|
387
374
|
dial_args += "|#{opts[:options]}" if opts[:options]
|
388
375
|
call_and_exec caller, "Dial", :args => dial_args, :caller_id => opts[:caller_id]
|
@@ -391,14 +378,12 @@ module Adhearsion
|
|
391
378
|
# hangup terminates a call accepts a channel as the argument
|
392
379
|
# full details here: http://www.voip-info.org/wiki/index.php?page=Asterisk+Manager+API+Action+Hangup
|
393
380
|
def hangup(channel)
|
394
|
-
#deprecation_warning
|
395
381
|
send_action "Hangup", :channel => channel
|
396
382
|
end
|
397
383
|
|
398
384
|
# call_and_exec allows you to make a call to a channel and then execute an Astersik application
|
399
385
|
# on that call
|
400
386
|
def call_and_exec(channel, app, opts={})
|
401
|
-
#deprecation_warning
|
402
387
|
args = { :channel => channel, :application => app }
|
403
388
|
args[:caller_id] = opts[:caller_id] if opts[:caller_id]
|
404
389
|
args[:data] = opts[:args] if opts[:args]
|
@@ -411,7 +396,6 @@ module Adhearsion
|
|
411
396
|
#
|
412
397
|
# call_into_context('SIP/1000@sipnetworks.com', 'my_context', { :variables => { :session_guid => new_guid }})
|
413
398
|
def call_into_context(channel, context, options={})
|
414
|
-
#deprecation_warning
|
415
399
|
args = {:channel => channel, :context => context}
|
416
400
|
args[:priority] = options[:priority] || 1
|
417
401
|
args[:exten] = options[:extension] if options[:extension]
|
@@ -420,11 +404,18 @@ module Adhearsion
|
|
420
404
|
originate args
|
421
405
|
end
|
422
406
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
407
|
+
private
|
408
|
+
def _send_action_asynchronously(action_name, headers={})
|
409
|
+
check_action_name action_name
|
410
|
+
action = ManagerInterfaceAction.new(action_name, headers)
|
411
|
+
if action.replies_with_action_id?
|
412
|
+
@write_queue << action
|
413
|
+
action
|
414
|
+
else
|
415
|
+
raise NotImplementedError
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
428
419
|
|
429
420
|
|
430
421
|
protected
|
@@ -582,25 +573,22 @@ module Adhearsion
|
|
582
573
|
retry
|
583
574
|
end
|
584
575
|
|
585
|
-
def login_actions
|
586
|
-
|
587
|
-
|
588
|
-
if
|
589
|
-
|
576
|
+
def login_actions
|
577
|
+
response = send_action "Login", "Username" => @username, "Secret" => @password, "Events" => "Off"
|
578
|
+
ahn_log.ami "Successful AMI actions-only connection into #{@username}@#{@host}"
|
579
|
+
if @actions_lexer.ami_version < 1.1
|
580
|
+
@coreSettings = Hash.new
|
581
|
+
@coreSettings["AsteriskVersion"] = "1.4.0"
|
582
|
+
@coreSettings["AMIversion"] = "1.0"
|
583
|
+
@coreSettings["ArgumentDelimiter"] = "|"
|
590
584
|
else
|
591
|
-
|
592
|
-
|
593
|
-
@coreSettings = Hash.new
|
594
|
-
@coreSettings["AsteriskVersion"] = "1.4.0"
|
595
|
-
@coreSettings["AMIversion"] = "1.0"
|
596
|
-
@coreSettings["ArgumentDelimiter"] = "|"
|
597
|
-
else
|
598
|
-
@coreSettings = send_action_synchronously("CoreSettings").headers
|
599
|
-
@coreSettings["ArgumentDelimiter"] = ","
|
600
|
-
end
|
601
|
-
UnsupportedActionName::preinitialize(@coreSettings["AsteriskVersion"].to_f)
|
602
|
-
response
|
585
|
+
@coreSettings = send_action_synchronously("CoreSettings").headers
|
586
|
+
@coreSettings["ArgumentDelimiter"] = ","
|
603
587
|
end
|
588
|
+
UnsupportedActionName::preinitialize(@coreSettings["AsteriskVersion"].to_f)
|
589
|
+
response
|
590
|
+
rescue ManagerInterfaceError => e
|
591
|
+
raise AuthenticationFailedException, "Incorrect username and password! #{e.message}"
|
604
592
|
end
|
605
593
|
|
606
594
|
def disconnect_events_connection
|