Looking For Sample Hangup_handler_pop And _wipe Using Vars
Please point me to samples of popping and wiping hangup handlers. I don’t need to use the values returned; I just need to clear any handlers before I
push a new one.
It’s not clear at https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers+Specification how to provide vars on the right-hand side.
Cheers, David
One thought on - Looking For Sample Hangup_handler_pop And _wipe Using Vars
From the indicated wiki page:
*Pop a hangup handler off a channel and optionally push a replacement*
same => n,Set(CHANNEL(hangup_handler_pop)=[[[context,]exten,]priority[(arg1[,…][,argN])]]);
*Pop all hangup handlers off a channel and optionally push a replacement*
same => n,Set(CHANNEL(hangup_handler_wipe)=[[[context,]exten,]priority[(arg1[,…][,argN])]]);
What the syntax above is indicating is that the value to assign is
*optional*. Thus to only pop or wipe hangup handlers you *do not* provide a new handler to push.
[hdlr1]
exten = s,1,NoOp()
same = n,Return()
[hdlr2]
exten = s,1,NoOp()
same = n,Return()
[hdlr3]
exten = s,1,NoOp()
same = n,Return()
[my_new_handler_context]
exten = my_new_handler_exten,3,NoOp()
same = n,Return()
[my_current_context]
…
; This wipes all set hangup handlers because we are not providing an optional replacement handler to push onto the empty stack. same = n,NoOp() ; <-- At this point we may or may not have hangup handlers set on the channel same = n,Set(CHANNEL(hangup_handler_wipe)=) same = n,NoOp() ; <-- At this point we have no hangup handlers on the channel ; This wipes all set hangup handlers and pushes a new one onto the empty stack. same = n,NoOp() ; <-- At this point we may or may not have hangup handlers set on the channel same n,Set(CHANNEL(hangup_handler_wipe)=my_new_handler_context,my_new_handler_exten,3) same = n,NoOp() ; <-- At this point we have only the one hangup handler we just pushed: my_new_handler_context,my_new_handler_exten,3 ; Hangup handler test dialplan exten = 101,1,NoOp() same = n,Set(CHANNEL(hangup_handler_push)=hdlr1,s,1) same = n,Set(CHANNEL(hangup_handler_push)=hdlr2,s,1) same = n,Set(CHANNEL(hangup_handler_push)=hdlr3,s,1) ; What is the hangup handler stack when the channel is in the Echo application? same = n,Echo() same = n,Hangup() exten = 102,1,NoOp() same = n,Set(CHANNEL(hangup_handler_push)=hdlr1,s,1) same = n,Set(CHANNEL(hangup_handler_push)=hdlr2,s,1) same = n,Set(CHANNEL(hangup_handler_push)=hdlr3,s,1) same n,Set(CHANNEL(hangup_handler_pop)=my_new_handler_context,my_new_handler_exten,3) ; What is the hangup handler stack when the channel is in the Echo application? same = n,Echo() same = n,Hangup() exten = 103,1,NoOp() same = n,Set(CHANNEL(hangup_handler_push)=hdlr1,s,1) same = n,Set(CHANNEL(hangup_handler_push)=hdlr2,s,1) same = n,Set(CHANNEL(hangup_handler_push)=hdlr3,s,1) same n,Set(CHANNEL(hangup_handler_pop)=my_new_handler_context,my_new_handler_exten,3) ; What is the hangup handler stack when the channel is in the Echo application? same = n,Echo() same = n,Hangup() You can enter the test dialplan portion above. Then call the test extensions to see what is on the channel’s hangup handler stack while the channel is in the Echo application by using the command line commands mentioned on the wiki page. Richard