Author Topic: javascript routing, redis  (Read 9218 times)

evgeniy

  • Newbie
  • *
  • Posts: 6
    • View Profile
javascript routing, redis
« on: June 30, 2016, 08:33:39 AM »
How can I request redis from javascript routing script? Or do http request?
Do I need to patch javascript.cpp ?

Also JSON object is not defined in javascript routing script, how can I enable it?
http://docs.yate.ro/wiki/Javascript_Reference

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: javascript routing, redis
« Reply #1 on: July 01, 2016, 01:13:56 AM »
If you need database access:
See 'database' message description
http://docs.yate.ro/wiki/Database
Yate has support for mysql, postgresql, sqlite

JSON:
var obj = {};
var str = JSON.stringify(obj);
obj = JSON.parse(str);


evgeniy

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: javascript routing, redis
« Reply #2 on: July 01, 2016, 01:51:09 AM »
Thank you for help.

Regarding JSON, I tried exacly your example, but it fails.
<JsCode:WARN> Evaluator error: Function 'JSON.stringify' call failed in routing.js:2:
Code: [Select]
var obj = {};
var str = JSON.stringify(obj);
obj = JSON.parse(str);

Looks like I dont have JSON at all, any call fails.
I Tried this:
Code: [Select]
Engine.output("JSON module: " + JSON);
Engine.output("File module: " + File);

and get output:
Code: [Select]
JSON module:
File module: [object File]

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: javascript routing, redis
« Reply #3 on: July 01, 2016, 02:42:39 AM »
JSON support was added in 2014.
Unless you redefined the JSON object the example should work (I tested it).
You don't have to create a JSON object.
The following will lead to failure:
var j = new JSON;
j.stringify(some_object);

You should update to latest svn version anyway.