[Freeswitch-users] Freeswitch creating more then two sessions for one call

Shoaib Khanzada skhanzada at gmail.com
Sat Jun 6 00:53:59 PDT 2009


Following is the js i am using to select route and bridge the call....


use("ODBC");

var DSN         = "myodbc";
var DB_USER = "neo";
var DB_PASS = ".....";

var sql;

var prefix1;
var ip1;
var no2;

var bridge_str;

if(argv[0]=="")
exit();


if(argv[1]=="")
exit();


ip1 =argv[0].split("@")[1];


var no1=argv[1];

var sql = "SELECT id,prefix,name FROM internal_auth where
substring('"+no1+"',1,length(prefix))=prefix and ip='" + ip1 +"' and
active=1;";

var authName="";

var db = new ODBC(DSN, DB_USER, DB_PASS);

db.connect();

db.query(sql);

if(db.nextRow()) {

     var row = db.getData();

    if (row["id"] == "" ) {
        console_log("Err", "auth failed(0001)\t" + no1 + "\targ[0]=>" +
argv[0] + "\targ[1]=>" + argv[1] + "\n");
        db.close();
         exit();
    }

    prefix1=row["prefix"]; authName=row["name"];

}else{
        console_log("Err", "auth failed(0001)\t" + no1 + "\targ[0]=>" +
argv[0] + "\targ[1]=>" + argv[1] + "\n");
        db.close();
         exit();

}


no2=no1.substring(prefix1.length, no1.length);

sql = "SELECT  ec.* FROM auth_routes_carriers arc,external_carriers ec,
codes c where arc.external_carriers_id = ec.id and arc.code_id = c.id and
substring('"+no2+"',1,length(c.code))=c.code and ec.active=1 order by
arc.priority asc";

db.connect();

db.query(sql);

var carriersName="";

bridge_str='';

while(db.nextRow()) {

    var row = db.getData();

    if (row["id"] != "" ) {
        bridge_str = row["gateway"]+row["prefix"]+no2+"\@"+row["ip"];
          carriersName = row["name"];
           break;
    }

}

db.close();

if(bridge_str != ''){
    if(session.ready()) session.execute("bridge", bridge_str);
}
else {
    console_log("Err", "external carrier not found.\t" + no2 + "\targ[0]=>"
+ argv[0] + "\targ[1]=>" + argv[1] + "\n");
    exit();
}


exit();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20090606/f73b2bae/attachment-0002.html 


More information about the FreeSWITCH-users mailing list