[Asterisk-Users] How to do something random?
Mike Sander
mike at corporatebankinginternational.com
Mon Mar 28 21:58:46 MST 2005
Logically, you should build something like this:
1. Pick a number between 1 and 3
2. Save the number to a variable indicating which line you are about to try
3. Check if it's free, if so make a call
4. If not, pick a number between 1 and 2
5. Make sure you haven't tried this number before (a loop and perhaps an
array of line numbers)
6. When you find a not-yet-tried number, check if it's free. If so, make a
call
7. If not, loop again to find the remaining number, check if free, if so
make a call.
8. If you get here, all lines are busy - play the busy tone.
I'm sorry my coding is not up to scratch, but this seems like a good
application for an AGI script as it can do arrays and looping easier, and
you could build this up to many lines.
Mike
> Take a look at the Random() command.
>
> MARK.
>
> Ronald Wiplinger wrote:
>
>> I want to change the below lines:
>>
>> exten => _011.,1,SetGroup(line1) ; set current group to
>> line
>> exten => _011.,2,CheckGroup(1) ; check line1 does
>> not have more than 1
>> exten => _011.,3,Dial,SIP/${EXTEN}@line-a ; use line-1
>> exten => _011.,103,1,SetGroup(line2) ; set current
>> group to line
>> exten => _011.,104,CheckGroup(1) ; check line2 does not
>> have more than 1
>> exten => _011.,105,Dial,IAX2/xxxxx at line-b/${EXTEN} ; use line-2
>> exten => _011.,205,1,SetGroup(line3) ; set current
>> group to line
>> exten => _011.,206,CheckGroup(1) ; check line3 does not
>> have more than 1
>> exten => _011.,207,Dial,IAX2/xxxxx at line-b/${EXTEN} ; use line-3
>>
>> exten => _011.,307,Busy ; Play busy if all lines
>> already used
>>
>>
>> so that the three lines will be choosen random, but still only one
>> user per line.
>>
>> Can you give me a hint?
>> BTW, I have not tested the lines yet, ... if you spot an error, please
>> point it out.
>>
>>
>> bye
>>
>> Ronald
>>
>> _______________________________________________
>> Asterisk-Users mailing list
>> Asterisk-Users at lists.digium.com
>> http://lists.digium.com/mailman/listinfo/asterisk-users
>> To UNSUBSCRIBE or update options visit:
>> http://lists.digium.com/mailman/listinfo/asterisk-users
>
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
>
More information about the asterisk-users
mailing list