Hi All,
<div><br></div><div>The following lua script for calculate the call duration. But the issue here , the duration is calculating from the outbound initiate time.</div><div><br></div><div>How to get the call answer time?</div>
<div><br></div><div><br></div><div><div><font class="Apple-style-span" face="verdana, sans-serif">session:preAnswer();</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">-- sleep a second</font></div>
<div><font class="Apple-style-span" face="verdana, sans-serif">session:sleep(1000);</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">--</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">digits = session:playAndGetDigits(10, 20, 3, 5000, "#", "enter-dest.wav", "invalid-digits.wav", "\\d+|\\*");</font></div>
<div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><font class="Apple-style-span" face="verdana, sans-serif">-- Initiate an outbound call</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">outSession = freeswitch.Session("sofia/gateway/voipms/"..digits,session)</font></div>
<div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><font class="Apple-style-span" face="verdana, sans-serif">starttime = os.time();</font></div>
<div><font class="Apple-style-span" face="verdana, sans-serif">freeswitch.consoleLog("info", "Start Time"..starttime.." \n");</font></div><div><font class="Apple-style-span" face="verdana, sans-serif"><br>
</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">freeswitch.consoleLog("info", "Before Bridge the Call \n");</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">freeswitch.bridge(session, outSession);</font></div>
<div><font class="Apple-style-span" face="verdana, sans-serif">freeswitch.consoleLog("info", "After Bridge the Call \n");</font></div><div><font class="Apple-style-span" face="verdana, sans-serif"><br>
</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">endtime = os.time();</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">freeswitch.consoleLog("info", "End Time"..endtime.." \n");</font></div>
<div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><font class="Apple-style-span" face="verdana, sans-serif">billsec = os.difftime(endtime,starttime);</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">freeswitch.consoleLog("info", "Blling Sec"..billsec.." \n");</font></div>
<div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><font class="Apple-style-span" face="verdana, sans-serif">-- hangup</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">session:hangup();</font></div>
<div><br></div><div><br></div><div>Thanks</div><div>Lloyd</div></div>