Javascript Rmanager commands: Difference between revisions

From Yate Documentation
Jump to navigation Jump to search
Line 23: Line 23:
==Evaluate expresion==
==Evaluate expresion==


Ask Javascript interpretor to evaluate expresion:
'''Ask Javascript interpretor to evaluate expresion''':
  javascript eval Engine.debug("test")
  javascript eval Engine.debug("test")


Ask Javascript interpretor to evaluate expresion in the context of a specific script. In this case you will be able to access global variables from that script.
'''Ask Javascript interpretor to evaluate expresion in the context of a specific script'''. In this case you will be able to access global variables from that script.
  javascript eval=script_name Engine.debug("test"+var_name)
  javascript eval=script_name Engine.debug("test"+var_name)


Ask Javascript interpretor to evaluate expresion in the context of a specific routing script instance. In this case you will be able to access global variables from that script instance.
'''Ask Javascript interpretor to evaluate expresion in the context of a specific routing script instance'''. In this case you will be able to access global variables from that script instance.
  javascript eval=chan_id Engine.debug("test"+var_name)
  javascript eval=chan_id Engine.debug("test"+var_name)


Ex:
Ex:
  javascript eval=sip/74 Engine.debug("test"+var_name)
  javascript eval=sip/74 Engine.debug("test"+var_name)
You can use the eval functionality to test javascript expressions and in some cases it's very usefull when debugging.




[[Category:Javascript]] [[Category:Rmanager]]
[[Category:Javascript]] [[Category:Rmanager]]

Revision as of 11:21, 26 February 2014

You can interact with Javascript scripts from rmanager.

To connect to Yate's rmanager interface

telnet 127.0.0.1 5038

See running scripts

javascript info

Ex output:

javascript info
nib = ./share/scripts/nib.js
sip/74: ReRoute

nib.js is a global script and sip/74 is a sip channel that is assisted by the configured routing script

Reload scripts

You can use this to reload a script after you have modified it.

javascript reload script_name

Evaluate expresion

Ask Javascript interpretor to evaluate expresion:

javascript eval Engine.debug("test")

Ask Javascript interpretor to evaluate expresion in the context of a specific script. In this case you will be able to access global variables from that script.

javascript eval=script_name Engine.debug("test"+var_name)

Ask Javascript interpretor to evaluate expresion in the context of a specific routing script instance. In this case you will be able to access global variables from that script instance.

javascript eval=chan_id Engine.debug("test"+var_name)

Ex:

javascript eval=sip/74 Engine.debug("test"+var_name)

You can use the eval functionality to test javascript expressions and in some cases it's very usefull when debugging.