Hi All,

The following lua script for calculate the call duration. But the issue here , the duration is calculating from the outbound initiate time.

How to get the call answer time?


session:preAnswer();
-- sleep a second
session:sleep(1000);
--
digits = session:playAndGetDigits(10, 20, 3, 5000, "#", "enter-dest.wav", "invalid-digits.wav", "\\d+|\\*");

-- Initiate an outbound call
outSession = freeswitch.Session("sofia/gateway/voipms/"..digits,session)


starttime  = os.time();
freeswitch.consoleLog("info",   "Start Time"..starttime.." \n");

freeswitch.consoleLog("info",   "Before Bridge the Call \n");
freeswitch.bridge(session, outSession);
freeswitch.consoleLog("info",   "After Bridge the Call \n");

endtime = os.time();
freeswitch.consoleLog("info",   "End Time"..endtime.." \n");

billsec = os.difftime(endtime,starttime);
freeswitch.consoleLog("info",   "Blling Sec"..billsec.." \n");

-- hangup
session:hangup();


Thanks
Lloyd