Javascript Rmanager commands: Difference between revisions

From Yate Documentation
Jump to navigation Jump to search
No edit summary
No edit summary
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
You can interact with Javascript scripts from [[rmanager]].
You can interact with Javascript scripts from [[rmanager]]. The javascript rmanager commands are a great tool to help you debug javascript applications.


To connect to Yate's rmanager interface
To connect to Yate's rmanager interface


  telnet 127.0.0.1 5038
  telnet 127.0.0.1 5038


==See running scripts==
==See running scripts==
Line 11: Line 12:
Ex output:
Ex output:
  javascript info
  javascript info
  nib = ./share/scripts/nib.js
  nip = ./share/scripts/nip.js
  sip/74: ReRoute
  sip/74: ReRoute


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


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


  javascript reload script_name
  javascript reload script_name
Line 22: Line 24:
==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)


Line 34: Line 36:
  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 useful when debugging.
==Inspecting variables==
'''Inspect variable in running script''':
javascript eval=script_name Engine.print_r(var_name)
'''View Object or Array in JSON format''':
javascript eval=script_name JSON.stringify(var_name,null,2)


[[Category:Javascript]] [[Category:Rmanager]]
[[Category:Javascript]] [[Category:Rmanager]]
==See installed message handlers==
You can use even use '''eval''' to see installed handlers for a script. This help a lot to debug scripts especially when you include functionality from multiple files.
Command:
    javascript eval=roaming Engine.print_t(Message.handlers())
Example output:
    name              priority handler        trackName    filterName filterValue
    ----------------- -------- -------------- ------------- ---------- ------------
    call.update      90      onChanUpdate  javascript:90
    sip.options      90      onSipOptions  javascript:90
    sip.info          90      onSipInfo      javascript:90
    module.update    90      onModuleUpdate javascript:90 module    ybts
    user.register    80      onRegister    roaming:80
    user.unregister  80      onUnregister  roaming:80
    call.route        80      onRoute        roaming:80
    auth              80      onAuth        roaming:80    callto    smsc_yatebts
    msg.execute      80      onMoSMS        roaming:80    module    ybts
    chan.disconnected 40      onDisconnected roaming:40    module    ybts
    chan.hangup      80      onHangup      roaming:80    module    ybts
    call.execute      80      onExecute      roaming:80    module    ybts
    call.progress    50      addPhyInfo    roaming:50    module    ybts
    call.ringing      50      addPhyInfo    roaming:50
    call.answered    50      addPhyInfo    roaming:50    module    roaming
    chan.dtmf        50      addPhyInfo    roaming:50
    engine.command    120      onCommand      roaming:120
    engine.help      150      onHelp        roaming:150
    engine.debug      150      onDebug        roaming:150
    engine.init      110      onReload      roaming:110

Latest revision as of 09:46, 21 August 2017

You can interact with Javascript scripts from rmanager. The javascript rmanager commands are a great tool to help you debug javascript applications.

To connect to Yate's rmanager interface

telnet 127.0.0.1 5038


See running scripts

javascript info

Ex output:

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

nip.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 useful when debugging.

Inspecting variables

Inspect variable in running script:

javascript eval=script_name Engine.print_r(var_name)

View Object or Array in JSON format:

javascript eval=script_name JSON.stringify(var_name,null,2) 

See installed message handlers

You can use even use eval to see installed handlers for a script. This help a lot to debug scripts especially when you include functionality from multiple files.

Command:

   javascript eval=roaming Engine.print_t(Message.handlers())

Example output:

   name              priority handler        trackName     filterName filterValue
   ----------------- -------- -------------- ------------- ---------- ------------
   call.update       90       onChanUpdate   javascript:90
   sip.options       90       onSipOptions   javascript:90
   sip.info          90       onSipInfo      javascript:90
   module.update     90       onModuleUpdate javascript:90 module     ybts
   user.register     80       onRegister     roaming:80
   user.unregister   80       onUnregister   roaming:80
   call.route        80       onRoute        roaming:80
   auth              80       onAuth         roaming:80    callto     smsc_yatebts
   msg.execute       80       onMoSMS        roaming:80    module     ybts
   chan.disconnected 40       onDisconnected roaming:40    module     ybts
   chan.hangup       80       onHangup       roaming:80    module     ybts
   call.execute      80       onExecute      roaming:80    module     ybts
   call.progress     50       addPhyInfo     roaming:50    module     ybts
   call.ringing      50       addPhyInfo     roaming:50
   call.answered     50       addPhyInfo     roaming:50    module     roaming
   chan.dtmf         50       addPhyInfo     roaming:50
   engine.command    120      onCommand      roaming:120
   engine.help       150      onHelp         roaming:150
   engine.debug      150      onDebug        roaming:150
   engine.init       110      onReload       roaming:110