[asterisk-users] application call to Gosub affects flow of control, and needs to be re-written using AEL

Benoit maverick at maverick.eu.org
Fri Jul 23 08:50:18 CDT 2010


Hi,

For some reason (outbound call tracking) I've got a few different 
outbound call process (using a macro for queuemetrics logging, or direct 
call)
i wanted to factorise the routing process so i came up with something 
like the following. All in one it's working like expected, however
every "ael reload" command trigger a lot of warning like that

     "application call to Gosub affects flow of control, and needs to be 
re-written using AEL if, while, goto, etc. keywords instead!"

But i fail to see how i could do it another way, any idea/suggestion ?


Extraction of the outbound processing structure:

context outboundSimple {
         _9X. => {
                 // prepare callerid, secret, ...
                 /// ...

                 // start call routing
                 Gosub(pstnRouting,${EXTEN:1},1);
                 // back, handle return status
&dialstatus(${DIALSTATUS},${EXTEN:1});
                 }
}

context outboundQueue1 {
         _9X. => {
                 // prepare callerid, secret, ...
                 /// ...

&qmoutqdial(${EXTEN:1},DAHDI/g1/${EXTEN:1},queue-out,Agent/${AgentNum});
                 }
}

context outboundQueue2 {
....
}

// outbound call logging for queuemetrics:
macro qmoutqdial( clid, dialstring, queue, agent )
{
         start_dial_time = ${EPOCH};
         QueueLog(${queue},${UNIQUEID},${agent},CALLOUTBOUND,-|${clid});

         
Set(dialopts=gWKU(queuelog_connect_event^${queue}^${UNIQUEID}^${agent}^${start_dial_time}));
         Gosub(pstnRouting,${clid},1);

         end_dial_time = ${EPOCH};
         verb = COMPLETECALLER;
&queuelog_hangup_event(${queue},${UNIQUEID},${agent},${start_dial_time});
         return;
}


// central call routing rules
context pstnRouting {

         _06XXXXXXXX => { Gosub(pstnInterface2,${EXTEN},1); Return; }
         ....

         // left over
         _X. =>  { Gosub(pstnInterface1,${EXTEN},1); Return; }
}

context pstnInterface1 {
         _X. => {
                 // setup the interface callerid/secret status

                 ChanIsAvail(DAHDI/g1);
                 if( ! ${ISNULL(${AVAILORIGCHAN})} ) {
                         Dial(DAHDI/g1/${ext},,${dialopts});
                 }
                 Return;
                 }
}

context pstnInterface2 {
         _X. => {
                 // setup the interface callerid/secret status

                 ChanIsAvail(SIP/....);
                 if( ! ${ISNULL(${AVAILORIGCHAN})} ) {
                         Dial(SIP/.../${ext},,${dialopts});
                 }
                 Return;
                 }
}




More information about the asterisk-users mailing list