[asterisk-users] Re: 'h' extension and which one applies?

Andrew Kohlsmith akohlsmith-asterisk at benshaw.com
Tue Feb 6 07:05:56 MST 2007


On Tuesday 06 February 2007 7:02 am, Andrea Spadaccini wrote:
> This would surely be more intuitive and would require less dialplan
> programming when there are more than one point where one might get an
> hangup and hangup conditions must be handled (i.e.
> Vicidial/Astguiclient).

So then just do what I do:

[macro-pri-dial]
exten => s,1,Dial(Zap/g1/${ARG1},,g)
exten => s,n,GotoIf($[${DIALSTATUS} = ANSWER]?h,1)
exten => s,n,GotoIf($[${DIALSTATUS} = NOANSWER]?h,1)
exten => s,n,GotoIf($[${DIALSTATUS} = BUSY]?h,1)
exten => s,n,GotoIf($[${DIALSTATUS} = CONGESTION]?h,1)
exten => s,n,NoOp(PRI-DIAL: Unusual Dialstatus "${DIALSTATUS}")
exten => s,n,Hangup

exten => h,1,NoOp(h exten hit in pri-dial macro)
exten => h,n,Macro(handle-hangup)

My macro is actually more complex than this, but you get the idea; My 
handle-hangup macro checks both HANGUPCAUSE and DIALSTATUS to figure out what 
to do next, and my VOIP peer dialing macros take a CONGESTION or CHANUNAVAIL 
dialstatus and dial out the PRI (i.e. automatic failover).

No matter if I hang up or the other side hangs up, I end up in my 'h' 
extension.  For some of my extensions, this cleans up the call recording or 
updates database status.  I don't seem to have any issues with this setup at 
all, and if I need to do something special based on who hung up, I can:

exten => _NXXNXXXXXX,1,Set(HANGER_UP=)
exten => _NXXNXXXXXX,n,Dial(SIP/${EXTEN}@peer,,g)
exten => _NXXNXXXXXX,n,Set(HANGER_UP=CALLEE)
exten => _NXXNXXXXXX,n,Goto(h,1)

exten => h,1,GotoIf($[${LEN(${HANGER_UP})} != 0]?gothu)
exten => h,n,Set(HANGER_UP=CALLER)
exten => h,n(gothu),NoOp(The ${HANGER_UP} hung up)
exten => h,n,Macro(handle-hangup)

Any questions?  :-)

-A.


More information about the asterisk-users mailing list