This module allows executing JavaScript scripts from the Kamailio configuration file. It exports all KEMI functions to JavaScript in order to access the currently processed SIP message. These functions are named within the JavaScript object 'KSR'. The module is based on the Duktape JavaScript engine (http://www.duktape.org), which is a fast and easy to embed JavaScript interpreter. The exported API from Kamailio to JavaScript is documented in the wiki. The module has two JavaScript contexts: * first is used for functions jsdt_dofile() and jsdt_dostring(). * second is used for function jsdt_run() and parameter 'load' and 'loaddir'. Therefore jsdt_run() cannot execute functions from scripts loaded via jsdt_dofile() in config. This is kind of caching mode, avoiding reading file every time, but you must be sure you do not have something that is executed by default and requires access to SIP message. This environment is also used by KEMI framework for the config SIP routing functions.
| Parámetro | Tipo | Descripción |
|---|---|---|
| load | str | 3.2. loaddir (str) 3.3. mode (int) |
| loaddir | str | 3.3. mode (int) |
| mode | int | 3.1. load (str) |
| load | str | Set the path to the JavaScript file to be loaded at startup. Then you can use jsdt_run(function, params) to execute a function from the script at runtime. If you use it for KEMI configuration, then it |
| loaddir | str | Set the path to the folder containing JavaScript files to be loaded at startup. All .js files in the folder will be loaded and combined into a single javascript script. Then you can use jsdt_run(funct |
| mode | int | Control if the API to load JavaScript module (nodejs interface) is initialized or not. |
4.2. jsdt_dostring(script) 4.3. jsdt_run(function, params) 4.4. jsdt_runstring(script)
4.3. jsdt_run(function, params) 4.4. jsdt_runstring(script)
4.4. jsdt_runstring(script)
4.1. jsdt_dofile(path)
Execute the JavaScript script stored in 'path'. The parameter can be a string with pseudo-variables evaluated at runtime.
Execute the JavaScript script stored in parameter. The parameter can be a string with pseudo-variables.
Execute the JS function 'func' giving params as parameters. There can be up to 3 string parameters. The function must exist in the script loaded at startup via parameter 'load'. Parameters can be strings with pseudo-variables that are evaluated at ru
Execute the JS script stored in parameter. The parameter can be a string with pseudo-variables. The script is executed in JS context specific to loaded JS files at startup.
Copyright © 2017 Daniel-Constantin Mierla (asipto.com)