[Freeswitch-users] javascript calculate duration of call

Brian West brian at freeswitch.com
Fri Mar 30 17:52:49 UTC 2018


You're already doing it wrong if you're taking this approach. Review our
existing CDR modules that would accomplish this for you.

/b


On Fri, Mar 30, 2018 at 3:20 AM, Francesco Facco de Lagarda <
francesco at delagarda.com> wrote:

> 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!
>
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>



-- 

Brian West | Co-founder and Developer

Need Commercial support? email sales at freeswitch.com

FreeSWITCH Solutions | 17345 Civic Drive #2531 Brookfield, WI 53045
<https://maps.google.com/?q=17345+Civic+Drive+%232531+Brookfield,+WI+53045&entry=gmail&source=g>

Email: brian at freeswitch.com

Mobile: 918-424-9378

Website: https://www.FreeSWITCH.com <https://www.freeswitch.com/>

[image: color-facebook-96.png] <https://www.facebook.com/freeswitch/>[image:
color-twitter-96.png]
<https://twitter.com/freeswitch?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20180330/6ae81fa2/attachment.html>


More information about the FreeSWITCH-users mailing list