[ previous ] [ next ] [ threads ]
 To : 
 From :  Diana Cionoiu <diana-liste@v...>
 Subject :  Re: [yate] Embedded scripting proposal
 Date :  Tue, 05 Oct 2010 15:07:22 +0300
Hello Gerry,

1. Yes, that's the point. We want some modules like pbxassist and some 
modules that require database processing to be done in Javascript. A 
scripting language it's good because a lot of things can be developed 
faster.

2. As usual this language will be yet another yate module therefor you 
will be able to disable it any time.

3. The problem is that asterisk dialplan name now it's asterisk 
extension language.

Diana

G.Jacobsen wrote:
> Paul,
>
> Given the proposed functionality ultimately that means that some existing
> Yate modules could be completely replaced by Javascript applications. And at
> the end, yate itself could simply become some sort of javascript
> interpreter.
>
> If not, Yate would become a mixed bag of C++ code and some Javascript ... I
> think you are at some cross-road here.
>
> As far as I am concerned, an asterisk-like dialplan where one can knock-up
> an application in no time and without worrying to break the entire system
> due to some unforeseen complexity would be just fine.
>
> Just my two pence.
>
> Cheers
>
> Gerry
>
>
>
>
> ----- Original Message ----- 
> From: "Paul Chitescu" 
> To: "Yate List" 
> Sent: Monday, October 04, 2010 5:48 PM
> Subject: [yate] Embedded scripting proposal
>
>
>   
>> Hi people!
>>
>> We decided to introduce embedded scripting in Yate as a more powerful
>> alternative to regexroute and external modules. We want to know your
>> questions, opinions and improvement suggestions.
>>
>> The reason to introduce scripting in Yate is to be able to perform complex
>> routing and IVR like functions without the drawback of running an external
>> interpreter. A script running in an external interpreter is slower to
>>     
> start,
>   
>> has more overhead processing the messages and cannot use all functionality
>>     
> of
>   
>> Yate. While regexroute can do arbitrary message processing it cannot keep
>>     
> a
>   
>> context associated with each call and the language itself is very weak.
>>
>> We are choosing the Javascript language. It is simple enough to be used by
>> beginners and basic functionality can be extended by experts. Moreover,
>>     
> there
>   
>> are several implementation libraries suitable for embedding.
>>
>> We plan for the script instances to sit besides the controlled call legs
>>     
> just
>   
>> like pbxassist does now. The script will be able to control the call flow
>>     
> and
>   
>> route the call to various destinations.
>>
>> A set of (Javascript) expressions will select which instruction block to
>> instantiate for each incoming call, much like we do now in regexroute.
>>     
> Once an
>   
>> instance is created all further interaction will occur in that context.
>>
>>
>> // optional, reserved for future compatibility
>> language javascript
>>
>> // include another file containing Javascript code
>> library "/path/to/library.js"
>>
>> // declare a function we are going to use
>> function isAuth() {
>> return username != "";
>> }
>>
>> // send international calls of authenticated users directly to a gateway
>> // in this case there is no instruction block, just a route
>> called.match(/^00/) && isAuth()  ::  "sip/sip:" + called +
>> "@g..."
>>
>> // unauthenticated callers are not allowed to call outside
>> called.length >= 4 && !isAuth() :: { error("noauth"); }
>>
>> // secondary dialer, also declare it as a function
>> called == "1234" ::
>> secondary_dialer()
>> {
>> answer();
>> play("/path/to/prompt_file.au");
>> }
>>
>> // alternative for the above
>> function secondary_dialer2() { answer();
>>     
> play("/path/to/prompt_file.au"); }
>   
>> called == "1235" :: { secondary_dialer2(); }
>>
>> // match and use a global variable shared between all instances
>> getGlobal("chans_used") < 30 ::
>> {
>> setGlobal("chans_used",getGlobal("chans_used")+1);
>> ...
>> }
>>
>> // handling of later messages
>> called == "123456" :: {
>>
>> function onAnswer() {
>> ...
>> }
>>
>> function onHangup() {
>> ...
>> }
>>
>> // this code is executed on entering the block
>> ring("tone/ring");
>> sleep(1);
>> answer();
>> ...
>> }
>>
>> // include another scripting file with similar syntax
>> include "/path/to/next_script_control";
>>
>>
>> Paul
>>