Nybble Processing Mainframe

    next-yate-compat

    0.0.5 • Public • Published

    Next-Yate-Compat (experimental)

    Next-Yate-Compat is Nodejs interface library to the Yate external module (Yet Another Telephony Engine) compatible with javascript.yate module.

    This is the next level of abstraction over the Next-Yate library to provide some code compatibility with original javascript.yate API

    Compatibility table

    API javascrip.yate next-yate (*)
    Message.watch - yes
    Message.unwatch - yes
    Message.install yes yes
    Message.uninstall yes yes
    Message.enqueue yes yes void
    Message.dispatch yes yes async
    Message.handlers yes -
    Message.installHook yes -
    Message.uninstallHook yes -
    Message.trackName yes yes async
    Message.broadcast yes -
    Message.getParam yes yes
    Message.setParam yes yes
    Message.copyParams yes yes
    Message.retValue yes yes
    Message.msgTime yes yes
    Message.getColumn yes -
    Message.getRow yes -
    Message.getResult yes -
    Engine.output yes yes
    Engine.debug yes yes
    Engine.alarm yes yes
    Engine.sleep yes yes async
    Engine.usleep yes yes async
    Engine.yield yes -
    Engine.idle yes -
    Engine.restart yes -
    Engine.dump_r yes yes async
    Engine.print_r yes yes
    Engine.dump_t yes yes async
    Engine.print_t yes yes
    Engine.debugName yes yes
    Engine.debugLevel yes yes
    Engine.debugEnabled yes yes
    Engine.debugAt yes yes
    Engine.setDebug yes yes
    Engine.started yes yes
    Engine.runParams yes -
    Engine.configFile yes -
    Engine.setInterval yes yes
    Engine.setTimeout yes yes
    Engine.clearInterval yes yes
    Engine.clearTimeout yes yes
    Engine.loadLibrary yes -
    Engine.loadObject yes -
    Engine.replaceParams yes yes
    Engine.atob yes yes
    Engine.btoa yes yes
    Engine.atoh yes -
    Engine.htoa yes -
    Engine.btoh yes -
    Engine.htob yes -
    Engine.shared yes -
    Engine.name yes yes
    Math.abs yes yes
    Math.max yes yes
    Math.min yes yes
    Math.random yes yes different
    parseInt yes yes
    isNan yes -
    RegExp.test yes yes
    RegExp.valid yes -
    Date yes yes
    XML yes -
    Hasher yes -
    JSON.parse yes yes
    JSON.stringify yes yes
    JSON.loadFile yes -
    JSON.saveFile yes -
    JSON.replaceParams yes -
    DNS yes -
    Shared yes -
    File yes -
    ConfigFile yes -
    ConfigSection yes -
    Channel yes yes async
    String yes yes different

    Quick start

    Before starting

    (If you still don't know what Yate is https://docs.yate.ro/wiki/Main_Page)

    Make sure the Yate's module extmodule.yate is successfully loaded (https://docs.yate.ro/wiki/External_Module)

    yate.conf:

    [modules]
    extmodule.yate=true
    

    extmodule.conf:

    ; For network connection
    [listener sample]
    type=tcp
    addr=127.0.0.1
    port=5040
    role=global
    ;
    ; Local stdin/stdout connected scripts
    [scripts]
    myscript.sh=            ; Custom shell wrapper around Nodejs script
    node.sh=my_script.js    ; Run my_script.js with example wrapper: examples/node.sh
    

    Install

    npm install next-yate
    

    Network connected script

    example_compatible_api.js:

    const { Engine, Message } = require("next-yate-compat").getEngine({ host: "127.0.0.1" });
    
    Engine.output("Hello World!");

    Local connected script

    When launching your script, be sure that Nodejs will find the necessary libraries.

    extmodule.conf:

    [scripts]
    node.sh=my_scrypt.js
    

    Example of shell wrapper around Nodejs

    node.sh:

    #!/bin/sh
    
    SCRIPTS=/path_to/share/scripts
    export NODE_PATH=$SCRIPTS
    NODE=`which node`
    
    $NODE $SCRIPTS/$1
    

    Direct script execution in channel mode

    regexroute.conf:

    ^NNN=extmodule/nodata/node.sh example.js
    

    example.js

    const {Engine, Message, Channel} = require("next-yate-compat").getEngine({channel: true});
    Channel.init(main, {autoring: true});
    
    async function main(message) {
        await Channel.callTo("wave/play/./share/sounds/welcome.au");
        await Channel.answered();
        Channel.callJust("conf/333", {"lonely": true});
    }

    (Please find welcome.js in /examples)

    Examples

    /examples

    API

    javascript.yate API

    Install

    npm i next-yate-compat

    DownloadsWeekly Downloads

    0

    Version

    0.0.5

    License

    Apache-2.0

    Unpacked Size

    28.3 kB

    Total Files

    5

    Last publish

    Collaborators

    • olego