Added agent_heartbeat for 3way-press-1 outside-agents
git-svn-id: svn://192.168.202.10@3797 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -23,16 +23,17 @@
|
||||
#exten => _49907.,n,Hangup
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2023 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2024 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# changes:
|
||||
# 231113-2016 - First Build
|
||||
# 231118-1600 - Added endings for HUNGUP and TIMEOUT
|
||||
# 231227-1428 - Added multi-phone ability
|
||||
# 240114-0942 - Added agent_heartbeat
|
||||
#
|
||||
|
||||
$script = 'agi-3way_press_agent.agi';
|
||||
$build = '231227-1428';
|
||||
$build = '240114-0942';
|
||||
|
||||
$at='@';
|
||||
$S='*';
|
||||
@@ -406,7 +407,7 @@ if ( ($CALLphone_numbers_ct > 0) && (length($CALLphone_numbers) > 4) )
|
||||
$allCIDs .= "$VIDqueryCID|";
|
||||
|
||||
### 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='$CALLphone_numbers_ARY[$vp]',dialstring='$temp_prefix_code$CALLphone_numbers_ARY[$vp]',outbound_cid='$original_cid',user='$CALLuser',session_id='$CALLsession_id',server_ip='$CALLserver_ip',session_id_3way='',status='NEW';";
|
||||
$stmtA="INSERT INTO vicidial_3way_press_live SET call_date=\"$SQLdate\",caller_code='$calleridname',call_3way_id='$VIDqueryCID',lead_id='$lead_id',phone_number='$CALLphone_numbers_ARY[$vp]',dialstring='$temp_prefix_code$CALLphone_numbers_ARY[$vp]',outbound_cid='$original_cid',user='$CALLuser',session_id='$CALLsession_id',server_ip='$CALLserver_ip',session_id_3way='',status='NEW',agent_heartbeat=NOW();";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live INSERT: |$affected_rowsA|$stmtA|"; &agi_output;}
|
||||
@@ -436,7 +437,7 @@ else
|
||||
$allCIDs .= "$VIDqueryCID|";
|
||||
|
||||
### 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';";
|
||||
$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();";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live INSERT: |$affected_rowsA|$stmtA|"; &agi_output;}
|
||||
@@ -471,6 +472,13 @@ while ($wait_loop < 100)
|
||||
$AGI->stream_file('hold_tone');
|
||||
}
|
||||
|
||||
### Update agent_heartbeat on all outside-agent calls
|
||||
$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;}
|
||||
|
||||
### 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;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
|
||||
@@ -53,10 +53,11 @@
|
||||
# 231113-2041 - First Build
|
||||
# 231227-1427 - Added multi-phone ability
|
||||
# 240108-1503 - Added call_channel and call_transfer logging
|
||||
# 240114-0946 - Added check of agent_heartbeat
|
||||
#
|
||||
|
||||
$script = 'agi-3way_press_outside.agi';
|
||||
$build = '231227-1427';
|
||||
$build = '240114-0946';
|
||||
|
||||
$at='@';
|
||||
$S='*';
|
||||
@@ -332,7 +333,8 @@ $CALLsession_id='';
|
||||
$CALLuser='';
|
||||
$CALLlead_id='';
|
||||
$CALLsession_id_3way='';
|
||||
$stmtA = "SELECT server_ip,session_id,user,lead_id,session_id_3way FROM vicidial_3way_press_live where call_3way_id='$calleridname' order by call_date desc limit 1;";
|
||||
$CALLagent_heartbeat=0;
|
||||
$stmtA = "SELECT server_ip,session_id,user,lead_id,session_id_3way,UNIX_TIMESTAMP(agent_heartbeat) FROM vicidial_3way_press_live where call_3way_id='$calleridname' order by call_date desc limit 1;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
@@ -345,9 +347,39 @@ if ($sthArows > 0)
|
||||
$CALLuser = $aryA[2];
|
||||
$CALLlead_id = $aryA[3];
|
||||
$CALLsession_id_3way = $aryA[4];
|
||||
$CALLagent_heartbeat = $aryA[5];
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
$heartbeat_test = ( (time()) - 9);
|
||||
if ( ($sthArows > 0) && ($CALLagent_heartbeat <= $heartbeat_test) )
|
||||
{
|
||||
if ($AGILOG) {$agi_string = "3-WAY AGENT ERROR: heartbeat gone, exiting... |($CALLagent_heartbeat < $heartbeat_test)|$calleridname|"; &agi_output;}
|
||||
|
||||
### Update the call in vicidial_3way_press_live
|
||||
$stmtA="DELETE FROM vicidial_3way_press_live where call_3way_id='$calleridname';";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live agent gone DELETE: |$affected_rowsA|$stmtA|"; &agi_output;}
|
||||
|
||||
### Update the call in vicidial_3way_press_log
|
||||
$stmtA="UPDATE vicidial_3way_press_log SET result=CONCAT(result,'|Agent Gone: $SQLdate') where call_3way_id='$calleridname';";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log agent gone UPDATE: |$affected_rowsA|$stmtA|"; &agi_output;}
|
||||
|
||||
print "SET CONTEXT $context\n";
|
||||
$result = <STDIN>;
|
||||
checkresult($result);
|
||||
print "SET EXTENSION i\n";
|
||||
$result = <STDIN>;
|
||||
checkresult($result);
|
||||
print "SET PRIORITY 1\n";
|
||||
$result = <STDIN>;
|
||||
checkresult($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmtA = "SELECT user FROM vicidial_live_agents where lead_id='$lead_id' and server_ip='$CALLserver_ip' order by live_agent_id desc limit 1;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
@@ -451,7 +483,7 @@ if ($stage =~ /accepted/i)
|
||||
$AGI->stream_file('hold_tone');
|
||||
}
|
||||
|
||||
$stmtA = "SELECT status,session_id_3way FROM vicidial_3way_press_live where call_3way_id='$calleridname' order by call_date desc limit 1;";
|
||||
$stmtA = "SELECT status,session_id_3way,UNIX_TIMESTAMP(agent_heartbeat) FROM vicidial_3way_press_live where call_3way_id='$calleridname' order by call_date desc limit 1;";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
||||
$sthArows=$sthA->rows;
|
||||
@@ -459,11 +491,41 @@ if ($stage =~ /accepted/i)
|
||||
if ($sthArows > 0)
|
||||
{
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
$CALLstatus = $aryA[0];
|
||||
$CALLconf_exten = $aryA[1];
|
||||
$CALLstatus = $aryA[0];
|
||||
$CALLconf_exten = $aryA[1];
|
||||
$CALLagent_heartbeat = $aryA[2];
|
||||
}
|
||||
$sthA->finish();
|
||||
|
||||
$heartbeat_test = ( (time()) - 9);
|
||||
if ($CALLagent_heartbeat <= $heartbeat_test)
|
||||
{
|
||||
if ($AGILOG) {$agi_string = "3-WAY AGENT ERROR: heartbeat gone 2, exiting... |($CALLagent_heartbeat < $heartbeat_test)|$calleridname|"; &agi_output;}
|
||||
|
||||
### Update the call in vicidial_3way_press_live
|
||||
$stmtA="DELETE FROM vicidial_3way_press_live where call_3way_id='$calleridname';";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live agent gone 2 DELETE: |$affected_rowsA|$stmtA|"; &agi_output;}
|
||||
|
||||
### Update the call in vicidial_3way_press_log
|
||||
$stmtA="UPDATE vicidial_3way_press_log SET result=CONCAT(result,'|Agent Gone: $SQLdate') where call_3way_id='$calleridname';";
|
||||
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
||||
$affected_rowsA = $dbhA->do($stmtA);
|
||||
if ($AGILOG) {$agi_string = "-- vicidial_3way_press_log agent gone 2 UPDATE: |$affected_rowsA|$stmtA|"; &agi_output;}
|
||||
|
||||
print "SET CONTEXT $context\n";
|
||||
$result = <STDIN>;
|
||||
checkresult($result);
|
||||
print "SET EXTENSION i\n";
|
||||
$result = <STDIN>;
|
||||
checkresult($result);
|
||||
print "SET PRIORITY 1\n";
|
||||
$result = <STDIN>;
|
||||
checkresult($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ($CALLstatus =~ /RESERVED/) && (length($CALLconf_exten) > 0) )
|
||||
{
|
||||
### Update the call in vicidial_3way_press_live
|
||||
|
||||
Reference in New Issue
Block a user