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

BBLister bblister at gmail.com
Sun Jan 1 14:01:20 MSK 2012


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.



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