0.0.5 • Published 5 years ago

next-yate-compat v0.0.5

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
5 years ago

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

APIjavascrip.yatenext-yate(*)
Message.watch-yes
Message.unwatch-yes
Message.installyesyes
Message.uninstallyesyes
Message.enqueueyesyesvoid
Message.dispatchyesyesasync
Message.handlersyes-
Message.installHookyes-
Message.uninstallHookyes-
Message.trackNameyesyesasync
Message.broadcastyes-
Message.getParamyesyes
Message.setParamyesyes
Message.copyParamsyesyes
Message.retValueyesyes
Message.msgTimeyesyes
Message.getColumnyes-
Message.getRowyes-
Message.getResultyes-
Engine.outputyesyes
Engine.debugyesyes
Engine.alarmyesyes
Engine.sleepyesyesasync
Engine.usleepyesyesasync
Engine.yieldyes-
Engine.idleyes-
Engine.restartyes-
Engine.dump_ryesyesasync
Engine.print_ryesyes
Engine.dump_tyesyesasync
Engine.print_tyesyes
Engine.debugNameyesyes
Engine.debugLevelyesyes
Engine.debugEnabledyesyes
Engine.debugAtyesyes
Engine.setDebugyesyes
Engine.startedyesyes
Engine.runParamsyes-
Engine.configFileyes-
Engine.setIntervalyesyes
Engine.setTimeoutyesyes
Engine.clearIntervalyesyes
Engine.clearTimeoutyesyes
Engine.loadLibraryyes-
Engine.loadObjectyes-
Engine.replaceParamsyesyes
Engine.atobyesyes
Engine.btoayesyes
Engine.atohyes-
Engine.htoayes-
Engine.btohyes-
Engine.htobyes-
Engine.sharedyes-
Engine.nameyesyes
Math.absyesyes
Math.maxyesyes
Math.minyesyes
Math.randomyesyesdifferent
parseIntyesyes
isNanyes-
RegExp.testyesyes
RegExp.validyes-
Dateyesyes
XMLyes-
Hasheryes-
JSON.parseyesyes
JSON.stringifyyesyes
JSON.loadFileyes-
JSON.saveFileyes-
JSON.replaceParamsyes-
DNSyes-
Sharedyes-
Fileyes-
ConfigFileyes-
ConfigSectionyes-
Channelyesyesasync
Stringyesyesdifferent

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