[Freeswitch-users] Help with Javascript "minuteminder.js"

Peter Olsson peter.olsson at visionutveckling.se
Mon Jan 2 10:19:43 MSK 2012


I suggest using sched_broadcast instead. I don't think your javascript will ever work, since the loop will stop the calls from bridging correctly. The only thing that will happen on the b-leg is your loop, instead of sending RTP frames for the call.

/Peter

----- Reply message -----
Från: "BBLister" <bblister at gmail.com>
Datum: sön, jan 1, 2012 23:49
Rubrik: [Freeswitch-users] Help with Javascript "minuteminder.js"
Till: "freeswitch-users at lists.freeswitch.org" <freeswitch-users at lists.freeswitch.org>


Hi and happy new year,

I am trying to implement a simple minute minder javascript, that will play a beep
every minute in telephone call.

I am using execute_on_answer and I have specified before the bridge the following:

  <action application="export" data="nolocal:execute_on_answer=javascript minuteminder.js"/>



In the file minuteminder.js I have this code:

---------------------------------------------------------------------------------------
function beep(nr_or_tries,sv_uuid) {
        console_log("Action: Broadcasting beep on " + sv_uuid + "\n" );
        if (session.ready()) apiExecute("uuid_broadast" , sv_uuid + " b5/beep.wav");
}
  var nr_or_tries = 10;
  curDate = Date();
  console_log("Action: Entering loop at "+curDate);
  var sv_uuid = session.uuid;
  console_log("Action: Activating minute minder on session "+sv_uuid+"\n");
  session.answer();
  while (session.ready()) {
  console_log("Action: Entering while loop\n");
  while (nr_or_tries > 0 )      {
                                console_log("Action: Loop id" + nr_or_tries + "\n");
                                beep(nr_or_tries--,sv_uuid);
                                session.sleep(60000);
                                }

                        }
  console_log("Action: Finished\n");
exit();
---------------------------------------------------------------------------------------

I have put the console_log for debuging. When I make a call I see in my logfile
the message from console_log ("Action: Broadcasting beep....") and the session  number
and after this the error that Session is Not active:

2011-12-31 23:54:26.616866 [DEBUG] minuteminder.js:1 Action: Broadcasting beep on d78cf701-fa33-e111-ab5a-00241d71e483
2011-12-31 23:54:26.616866 [ERR] inline:1  Session is not active!


The Beep is not heard. I have tried many combinations to fix this but I always get "Session is not active".

What can I do in order to fix this?

Do I need session.answer() or session.read() or do I assume that the session is ready because this script
was called on "exeute_on_answer"?

Thank you very much in advance.

_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting at freeswitch.org
http://www.freeswitchsolutions.com




Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.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

!DSPAM:4f00e0cf32761527225430!




Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list