[Asterisk-Users] Re: FastAGI Command Execution
Tony Mountifield
tony at softins.clara.co.uk
Fri Jan 13 10:37:16 MST 2006
In article <645FEC31A18FE54A8721500CDD55A7B602C15309 at mail.oneeighty.com>,
Douglas Garstang <dgarstang at oneeighty.com> wrote:
> Tony,
>
> It isn't that simple. I was trying to implemt findme/followme functionality. A user dials a
> number, and then the agi looks up that dialled extension in MySQL. For that extension, there
> is a list of numbers to try in sequence. Any step in the sequence could even involve
> dialling multiple numbers at the same time.
>
> If extensions.conf calls out to a Fast AGI script to retrieve the first number to dial, and
> then the Fast AGI script sets certain variables before returning control to extensions.conf
> to actually perform the dial, that might work for the first number, but I can't think of any
> way for the state to be maintained, such that if all this was in a loop in extensions.conf,
> on the next call to the Fast AGI script, it could remember it's state and retrieve the next
> number in the list.
>
> Oh if only it where simple!
If I understand you correctly, I don't think you need a loop, if you are
prepared to accept a maximum possible length of the sequence. You could
just have the AGI set a channel variable for each step in the sequence,
where that channel variable can contain either a single extension to
dial (e.g. SIP/2001 or Zap/g1/15152221234 or Local/15152221234 at foo) or
a set of numbers to dial together (e.g. SIP/2001&SIP/2004).
You would then have a dialplan something like this:
[incoming]
exten => _X.,1,FastAGI(whatever|${EXTEN})
exten => _X.,2,GotoIf($[ "${NUMA}" = "" ]?notfound,1)
exten => _X.,3,Dial(${NUMA})
exten => _X.,4,GotoIf($[ "${NUMB}" = "" ]?notfound,1)
exten => _X.,5,Dial(${NUMB})
exten => _X.,6,GotoIf($[ "${NUMC}" = "" ]?notfound,1)
exten => _X.,7,Dial(${NUMC})
exten => _X.,8,GotoIf($[ "${NUMD}" = "" ]?notfound,1)
exten => _X.,9,Dial(${NUMD})
exten => _X.,10,GotoIf($[ "${NUME}" = "" ]?notfound,1)
exten => _X.,11,Dial(${NUME})
exten => _X.,12,Goto(notfound,1)
exten => notfound,1,Playback(im-sorry-i-cannot-locate-the-person-you-called)
exten => notfound,2,Hangup
So if three steps were found in the database, the AGI just sets NUMA, NUMB and
NUMC. If it reaches step 8, it jumps to "notfound" because NUMD is not set.
Your dialplan can have as many possible steps as you want, it's not expensive.
Cheers
Tony
--
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org
More information about the asterisk-users
mailing list