Added CLI flags for timeout and outside-agent dial timeout in the 3way-press-agent scripts
git-svn-id: svn://192.168.202.10@3800 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -19,9 +19,13 @@
|
||||
#exten => _49907.,1,Answer
|
||||
#exten => _49907.,n,NoOp(${CALLERID(name)})
|
||||
#exten => _49907.,n,Playback(sip-silence)
|
||||
#exten => _49907.,n,AGI(agi-3way_press_agent.agi)
|
||||
#exten => _49907.,n,AGI(agi-3way_press_agent.agi,start---50---30)
|
||||
#exten => _49907.,n,Hangup
|
||||
#
|
||||
# The CLI flags for the 'agi-3way_press_agent.agi' script above are:
|
||||
# - stage = 'start' is the only value for this variable
|
||||
# - 3way agent timeout = number of seconds after launching 3way outside-agent calls before this script times out
|
||||
# - 3way dial timeout = the Asterisk Dial() timeout for the 3way outside-agent calls
|
||||
#
|
||||
# Copyright (C) 2024 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
@@ -30,10 +34,11 @@
|
||||
# 231118-1600 - Added endings for HUNGUP and TIMEOUT
|
||||
# 231227-1428 - Added multi-phone ability
|
||||
# 240114-0942 - Added agent_heartbeat
|
||||
# 240116-2110 - Added CLI flags for timeout and outside-agent dial timeout
|
||||
#
|
||||
|
||||
$script = 'agi-3way_press_agent.agi';
|
||||
$build = '240114-0942';
|
||||
$build = '240116-2110';
|
||||
|
||||
$at='@';
|
||||
$S='*';
|
||||
@@ -41,6 +46,8 @@ $mel=1; # Mysql Error Log enabled = 1
|
||||
$mysql_log_count=272;
|
||||
$one_mysql_log=0;
|
||||
$MT[0]='';
|
||||
$timeout=100;
|
||||
$Local_dial_timeout=80;
|
||||
|
||||
|
||||
$now_date_epoch = time();
|
||||
@@ -183,7 +190,21 @@ if (length($ARGV[0])>1)
|
||||
### list of command-line array arguments:
|
||||
@ARGV_vars = split(/---/, $ARGV[0]);
|
||||
|
||||
$stage = $ARGV_vars[0];
|
||||
$stage = $ARGV_vars[0];
|
||||
$CLI_timeout = $ARGV_vars[1];
|
||||
$CLI_dial_timeout = $ARGV_vars[2];
|
||||
$CLI_timeout =~ s/\D//gi;
|
||||
if (length($CLI_timeout) > 0)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = " Timeout CLI override: $timeout -> $CLI_timeout"; &agi_output;}
|
||||
$timeout = $CLI_timeout;
|
||||
}
|
||||
$CLI_dial_timeout =~ s/\D//gi;
|
||||
if (length($CLI_dial_timeout) > 0)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = " Dial Timeout CLI override: $Local_dial_timeout -> $CLI_dial_timeout"; &agi_output;}
|
||||
$Local_dial_timeout = $CLI_dial_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
$|=1;
|
||||
@@ -399,6 +420,7 @@ if ( ($CALLphone_numbers_ct > 0) && (length($CALLphone_numbers) > 4) )
|
||||
$vp=0;
|
||||
$temp_phone_length = (length($CALLphone_numbers_ARY[$vp]) * -1);
|
||||
$temp_prefix_code = substr($dialstring,0,$temp_phone_length);
|
||||
$Local_dial_timeout = ($Local_dial_timeout * 1000);
|
||||
while ($vp < $CALLphone_numbers_ct)
|
||||
{
|
||||
$VIDqueryCID = "T$CIDdateD$vp$PADlead_id";
|
||||
@@ -419,7 +441,7 @@ if ( ($CALLphone_numbers_ct > 0) && (length($CALLphone_numbers) > 4) )
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log LOG INSERT: |$affected_rowsB|$stmtA|"; &agi_output;}
|
||||
|
||||
### Insert the outside-agent call into vicidial_manager
|
||||
$stmtA="INSERT INTO vicidial_manager values('','',NOW(),'NEW','N','$CALLserver_ip','','Originate','$VIDqueryCID','Channel: Local/$temp_prefix_code$CALLphone_numbers_ARY[$vp]$CALLcontext','Context: xfer_press_dialplan','Exten: s','Priority: 1','Callerid: $newcallerid','Variable: __lead_id=$lead_id','','','','');";
|
||||
$stmtA="INSERT INTO vicidial_manager values('','',NOW(),'NEW','N','$CALLserver_ip','','Originate','$VIDqueryCID','Channel: Local/$temp_prefix_code$CALLphone_numbers_ARY[$vp]$CALLcontext','Context: xfer_press_dialplan','Exten: s','Priority: 1','Callerid: $newcallerid','Timeout: $Local_dial_timeout','Variable: __lead_id=$lead_id','','','');";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsG = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_manager INSERT: |$affected_rowsG|$stmtA|"; &agi_output;}
|
||||
@@ -435,6 +457,7 @@ else
|
||||
$newcallerid = "\"$VIDqueryCID <$original_cid>\"";
|
||||
$CALLcontext = '@default';
|
||||
$allCIDs .= "$VIDqueryCID|";
|
||||
$Local_dial_timeout = ($Local_dial_timeout * 1000);
|
||||
|
||||
### Insert the call to vicidial_3way_press_live
|
||||
$stmtA="INSERT INTO vicidial_3way_press_live SET call_date=\"$SQLdate\",caller_code='$calleridname',call_3way_id='$VIDqueryCID',lead_id='$lead_id',phone_number='$phone_number',dialstring='$dialstring',outbound_cid='$original_cid',user='$CALLuser',session_id='$CALLsession_id',server_ip='$CALLserver_ip',session_id_3way='',status='NEW',agent_heartbeat=NOW();";
|
||||
@@ -449,7 +472,7 @@ else
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log LOG INSERT: |$affected_rowsB|$stmtA|"; &agi_output;}
|
||||
|
||||
### Insert the outside-agent call into vicidial_manager
|
||||
$stmtA="INSERT INTO vicidial_manager values('','',NOW(),'NEW','N','$CALLserver_ip','','Originate','$VIDqueryCID','Channel: Local/$dialstring$CALLcontext','Context: xfer_press_dialplan','Exten: s','Priority: 1','Callerid: $newcallerid','Variable: __lead_id=$lead_id','','','','');";
|
||||
$stmtA="INSERT INTO vicidial_manager values('','',NOW(),'NEW','N','$CALLserver_ip','','Originate','$VIDqueryCID','Channel: Local/$dialstring$CALLcontext','Context: xfer_press_dialplan','Exten: s','Priority: 1','Callerid: $newcallerid','Timeout: $Local_dial_timeout','Variable: __lead_id=$lead_id','','','');";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsG = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_manager INSERT: |$affected_rowsG|$stmtA|"; &agi_output;}
|
||||
@@ -464,7 +487,7 @@ $allCIDs =~ s/\|$//gi;
|
||||
$allCIDs =~ s/\|/','/gi;
|
||||
|
||||
$wait_loop=0;
|
||||
while ($wait_loop < 100)
|
||||
while ($wait_loop < $timeout)
|
||||
{
|
||||
usleep(1*990*1000);
|
||||
if ($wait_loop =~ /0$|5$/)
|
||||
@@ -476,7 +499,7 @@ while ($wait_loop < 100)
|
||||
$stmtA="UPDATE vicidial_3way_press_live SET agent_heartbeat=NOW() where call_3way_id IN('$allCIDs');";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live agent_heartbeat UPDATE: |$affected_rowsA|$stmtA|"; &agi_output;}
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live agent_heartbeat UPDATE $wait_loop: |$affected_rowsA|$stmtA|"; &agi_output;}
|
||||
|
||||
### Find all associated outside-agent calls
|
||||
$stmtA = "SELECT status,call_3way_id FROM vicidial_3way_press_live where call_3way_id IN('$allCIDs') order by status desc limit 11;";
|
||||
@@ -670,7 +693,7 @@ while ($wait_loop < 100)
|
||||
$wait_loop++;
|
||||
}
|
||||
|
||||
if ($wait_loop >= 100)
|
||||
if ($wait_loop >= $timeout)
|
||||
{
|
||||
### Update the call in vicidial_3way_press_log
|
||||
$stmtA="UPDATE vicidial_3way_press_log SET session_id_3way='$CALLconf_exten', result=CONCAT(result,'|Timeout: ',NOW()) where call_3way_id IN('$allCIDs');";
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#exten => s,1,Answer
|
||||
#exten => s,n,NoOp(${call_3way_id})
|
||||
#exten => s,n,NoOp(${CALLERID(name)})
|
||||
#exten => s,n,AGI(agi-3way_press_outside.agi,answered)
|
||||
#exten => s,n,AGI(agi-3way_press_outside.agi,answered---20)
|
||||
#exten => s,n,Playback(sip-silence)
|
||||
#exten => s,n,Wait(1)
|
||||
#exten => s,n,Background(outside-sales)
|
||||
@@ -54,10 +54,11 @@
|
||||
# 231227-1427 - Added multi-phone ability
|
||||
# 240108-1503 - Added call_channel and call_transfer logging
|
||||
# 240114-0946 - Added check of agent_heartbeat
|
||||
# 240116-2109 - Added CLI flag for timeout
|
||||
#
|
||||
|
||||
$script = 'agi-3way_press_outside.agi';
|
||||
$build = '240114-0946';
|
||||
$build = '240116-2109';
|
||||
|
||||
$at='@';
|
||||
$S='*';
|
||||
@@ -65,6 +66,7 @@ $mel=1; # Mysql Error Log enabled = 1
|
||||
$mysql_log_count=272;
|
||||
$one_mysql_log=0;
|
||||
$MT[0]='';
|
||||
$timeout=100;
|
||||
|
||||
|
||||
$now_date_epoch = time();
|
||||
@@ -207,6 +209,13 @@ if (length($ARGV[0])>1)
|
||||
@ARGV_vars = split(/---/, $ARGV[0]);
|
||||
|
||||
$stage = $ARGV_vars[0];
|
||||
$CLI_timeout = $ARGV_vars[1];
|
||||
$CLI_timeout =~ s/\D//gi;
|
||||
if (length($CLI_timeout) > 0)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = " Timeout CLI override: $timeout -> $CLI_timeout"; &agi_output;}
|
||||
$timeout = $CLI_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
$|=1;
|
||||
@@ -475,7 +484,7 @@ if ($stage =~ /accepted/i)
|
||||
$CALLstatus='';
|
||||
$CALLconf_exten='';
|
||||
$wait_loop=0;
|
||||
while ($wait_loop < 100)
|
||||
while ($wait_loop < $timeout)
|
||||
{
|
||||
usleep(1*990*1000);
|
||||
if ($wait_loop =~ /0$|5$/)
|
||||
|
||||
Reference in New Issue
Block a user