[OpenSIPS-Users] problem using scripting variables AND inject random delays

Bogdan-Andrei Iancu bogdan at voice-system.ro
Fri Nov 14 10:42:57 CET 2008


:Hi Amar,

amar mahmoud wrote:
> Hi all,
>        i am quite new to use opensips, i have been using SER since 
> last week.
>  
> i want to use opensips to inject a delay then relay SIP 
> messages, actually there is function "sleep" under cfgutils.so module, 
> i have tested it .. it is working fine, my problems are:
>  
> 1/ i have problem using scripting variable i want to do like that:
>  
>   # define variable
> $var(a) = 10;
>  
>  # then
>  
> sleep ("$var(a)");
>  
> but the config file does not accept that, it gives error  while when i 
> use  sleep("10") there is no problem... so do i have a problem using 
> that and if yes how can i solve this.
Indeed, the sleep() function does not accept as argument a variable - if 
you are interested in this, open a feature request on the project tracker:
    http://www.opensips.org/index.php?n=Development.Tracker
>  
> 2/ i need to implement this delay to be a random variate where i can 
> use different distribution like exponential or   normal, does any one 
> try to do that before or have an idea how i can implement that
>  
I know it is an ugly hack, but you might make it work using a while 
statement:
    instead of  :
    
           sleep ("$var(a)");
   
    do:
           $var(i) = 0;
            while($var(i) < $var(a)) {
                  sleep(1);
                 $var(i) = $var(i) + 1;
           }

Regards,
Bogdan          

> any ideas are appreciated.
>  
>  
> Amar
>  
>  
>   
>
> ------------------------------------------------------------------------
> Stay up to date on your PC, the Web, and your mobile phone with 
> Windows Live Click here 
> <http://clk.atdmt.com/MRT/go/119462413/direct/01/>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>   




More information about the Users mailing list