[asterisk-dev] Arbitrary hangup handlers [patch]

Benny Amorsen benny+usenet at amorsen.dk
Thu Sep 16 10:25:00 CDT 2010


Mark Murawski <markm at intellasoft.net> writes:

> I still don't know what the appropriate differentiation is for functions 
> and applications.  The nice thing about functions is you get a return 
> value.  With applications you have to set a channel variable with the 
> contained result.  Say if a hangup handler failed to add because the 
> dialplan didn't exist, it might be nice to check the return code.

IMHO, Error handling in Asterisk dial plan isn't realistic in practice.
If you are only returning 0 or an error value, then don't bother.

Otherwise you end up with

SET(error=ADDHANDLER(hangup,callqueueHangupHandler))

Obviously I don't speak for the actual developers, just as a random
Asterisk user.

Besides, your proposed syntax did not provide a return value either:

> Set(CHANNEL(addhanguphandler)="callqueueHangupHandler,s,1");
> Set(CHANNEL(addhanguphandler)="someotherHangupHandler,s,1");
> Set(CHANNEL(addhanguphandler)="yetanotherHangupHandler,s,1");

Instead you set a magic variable CHANNEL(addhanguphandler). Are you
meant to be able to query that variable afterwards? What would that
return?

You can also add a function like SET(handler=HANDLER(hangup) which would
return the last handler which was added. Then you could check that to
see if your handler was added correctly -- except someone else might
have added yet another handler, and then your dial plan will get
confused.


/Benny



More information about the asterisk-dev mailing list