Good morning all,

I will be using both digital (which knows when the other part answers) and analogue (when, at least in Italy, doesn’t!)

 

I need to  calculate the total duration of an outgoing call.

 

Calls also must have a preset max duration. I need to schedule a warning message (1 min before timeout) and a hangup (on timeout) for BOTH digital and analogue lines.

 

This is the core of the code, reduced to the bone:

 

var allowedSecs = 300; // max length 5 min …

 

session.answer();

var sessOut = new Session("sofia/gateway/realtoneFXO/" +  dialedNum + "@192.168.0.216:5060");

 

if (trunkIsDigital) {

sessOut.execute("set", "execute_on_answer_1=sched_hangup  " + allowedSects + " alloted_timeout")

sessOut.execute("set", "execute_on_answer_2=sched_broadcast + " + (allowedSects-10) +  " playback::" + soundDir + "one_min_left.wav both");

} else {

// will schedule message and hangup on allowedSecs + graceTime to be calculated according to destintation (time to ring/answer)

}

 

if (sessOut.ready()) {

bridge(session, sessOut);

}

sessOut.hangup();

session.hangup();

 

/***

HOW LONG DID THE CALL (bridge) ACTUALLY LAST?? .. for billing purposes

**/

 

 

 

Thanks and Happy Easter!