[Freeswitch-users] Freeswitch - mod_spidermonkey_curl bug?

Shamun toha md shamun.toha at gmail.com
Fri Oct 8 09:44:20 PDT 2010


Hello,

I have a very strange problem using mod_spidermonkey_curl in CentOS 5.5
x86_64 bit. Same setup i am using in other machine in Fedora 12, it works,
is there any bugs????????? I receive OK, but when i use to compare it fails
in logical statement.


FreeSWITCH Version 1.0.head (git-25ddef5 2010-09-24 01-55-54 +0200) Started.

Installation curl as:
==============
[root at a autoload_configs]# cat spidermonkey.conf.xml
<configuration name="spidermonkey.conf" description="Spider Monkey
JavaScript Plug-Ins">
  <modules>
    <load module="mod_spidermonkey_teletone"/>
    <load module="mod_spidermonkey_core_db"/>
    <load module="mod_spidermonkey_socket"/>
    <!--<load module="mod_spidermonkey_odbc"/>-->
*    <load module="mod_spidermonkey_curl" />*

  </modules>
</configuration>



.../scripts/helloworld.js:
============

use("CURL");
var menuselection = "";
var promptfordigits_dtmf_digits = "";
var invalidRetry = 0;

/* This is getting failed, in Centos, but in other machine it works */
function my_callback(string, arg)
{
  console_log("info", string);

  //string = 'OK'; // then it works!!
  //2010-10-08 18:40:53.585676 [INFO] mod_dialplan_xml.c:331 Processing 1002
<1002>->1200 in context default
 * //2010-10-08 18:41:23.842965 [INFO] helloworld.js:42 OK*
  //2010-10-08 18:41:35.962099 [NOTICE] switch_ivr.c:1480 Transfer
sofia/internal/1002 at z.com to XML[3000 at default]
  //2010-10-08 18:41:35.962099 [INFO] mod_dialplan_xml.c:331 Processing 1002
<1002>->3000 in context default
  //2010-10-08 18:41:43.134207 [NOTICE] sofia.c:528 Hangup sofia/internal/
z.com [CS_EXECUTE] [NORMAL_CLEARING]


  if (string=='OK') {

   //
   //
   //       <<<<<<<<<<<<<<<<<<------------------ It receive OK but it never
execute this two, and but it execute invalid macro
   //
   //
   //
   session.sayPhrase("valid", menuselection, "en");
   session.execute("transfer", '3000');
  } else {
   session.sayPhrase("invalid", menuselection, "en");
   return true;
}


/* FS wiki - example */
function promptfordigits_dtmf_callback(session, type, digits, arg)
{
   console_log("digit: " + digits.digit + "\n");
   promptfordigits_dtmf_digits += digits.digit;
   /* returning true does not interrupt the digit collection*/
   return(true);
}

/* FS wiki - example */
function promptfordigits(ivrsession, promptname, numdigits, timeout)
{
   var repeat = 0;

   console_log("saymenu: menu=[" + promptname + "] numdigits=[" + numdigits
+ "]\n");

   session.flushDigits();
   promptfordigits_dtmf_digits = "";

   while (ivrsession.ready() && promptfordigits_dtmf_digits.length <
numdigits && repeat < 3) {
       /* play phrase - if digit keyed while playing callback will catch
them.
       If less than numdigits collected we get the rest after the prompt.*/
       ivrsession.sayPhrase(promptname, numdigits, "en",
promptfordigits_dtmf_callback, "");

       console_log("Prompt done=[" + promptname + "] Collected " +
promptfordigits_dtmf_digits.length + " digits [" +
promptfordigits_dtmf_digits + "]\n");

       /* if caller still here and has not entered any selection yet (or
less than numdigits entered) - wait for the rest of the digits*/
       if (ivrsession.ready() && promptfordigits_dtmf_digits.length <
numdigits ) {
           promptfordigits_dtmf_digits += ivrsession.getDigits(numdigits -
promptfordigits_dtmf_digits.length, "", timeout);
           /* if still no selection or insufficient digits repeat menu */
           if (promptfordigits_dtmf_digits.length < numdigits) {
               promptfordigits_dtmf_digits = "";
               repeat++;
           }
       }
   }
   return(promptfordigits_dtmf_digits);
}



function retry()
{
  /* FS wiki - example */
  menuselection = promptfordigits(session, "DialByNumberMenu", 8, 6000);

  if ( session.ready() ) {

  var curl = new CURL();
  curl.run( "POST",
            "http://portal/conference/query",
            "om=" + menuselection + "&ty=__",
             my_callback,
             "my arg\n",
             "p:ier");

  }

}


/**
 * Let's answer our call
 */
session.answer();
retry();




Thanks & Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20101008/f97f9c60/attachment-0001.html 


More information about the FreeSWITCH-users mailing list