[asterisk-users] Reuse h extension?

Matthew Jordan mjordan at digium.com
Sat Sep 29 12:40:22 CDT 2012



----- Original Message -----
> From: "Steve Edwards" <asterisk.org at sedwards.com>
> To: "Asterisk Users Mailing List - Non-Commercial Discussion" <asterisk-users at lists.digium.com>
> Sent: Saturday, September 29, 2012 10:44:25 AM
> Subject: Re: [asterisk-users] Reuse h extension?
> 
> On Sat, 29 Sep 2012, Stefan at WPF wrote:
> 
> > I have 2 contexts, however both have the same h extension.
> > Currently I am doing copy&paste for the h extension - is there a
> > better way?
> > Can I somehow reference a h extension, so I have to create/modify
> > it only once?

In addition to Steve's approach using templates, in Asterisk 11, you'll be able
to use hangup handlers.  These are subroutines that can be attached to a channel
and are executed after the channel is hung up.

[hangup_handler]

exten => my_handler,1,NoOp()
same => n,Verbose(Execute your normal 'h' extension logic here)
same => n,Return()

[context_1]

exten => 123,1,NoOp()
same => n,Set(CHANNEL(hangup_handler_push)=hangup_handler,my_handler,1)
same => n,Verbose(do stuff)

[context_2]

exten => 123,1,NoOp()
same => n,Set(CHANNEL(hangup_handler_push)=hangup_handler,my_handler,1)
same => n,Verbose(do stuff)


More on hangup handlers is available here:

https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers

--
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org



More information about the asterisk-users mailing list