1. Overview

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'. 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 someting 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.

2. Dependencies

2.1. Kamailio Modules

The following modules must be loaded before this module:

none.

2.2. External Libraries or Applications

The following libraries or applications must be installed before running
Kamailio with this module loaded:

libm - the math library (part of standard
system libraries - it is needed to complile embedded Duktape JS
interpreter).

3. Parameters

3.1. 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 has to include the requited functions.

4.3.
jsdt_run(function, params)

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 runtime.