<div dir="ltr"><div class="gmail_default"><span style="font-family:monospace,monospace">Keep it as simple as you can.</span></div><div class="gmail_default"><span style="font-family:monospace,monospace"><br></span></div><div class="gmail_default"><span style="font-family:monospace,monospace"></span><font face="monospace, monospace">[test]</font></div><div class="gmail_default"><font face="monospace, monospace">exten => 12345678900,1,Noop(#### Set callER hangup handler CHANNEL(name)='${CHANNEL(name)}' SIPCALLID='${SIPCALLID}')</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Set(CHANNEL(hangup_handler_push)=test_caller_hangup,${EXTEN},1)</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Dial(SIP/pbx-nyigc/4408,60,gb(test_pre_dial^${EXTEN}^1)F(test_intercept_callee,${EXTEN},1))</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Noop(### Running post Dial() dialplan on callER CHANNEL(name)='${CHANNEL(name)}' SIPCALLID='${SIPCALLID}')</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Gosub(test_intercept_caller,${EXTEN},1)</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Hangup</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">[test_pre_dial]</font></div><div class="gmail_default"><font face="monospace, monospace">exten => _X.,1,Noop(#### Set callEE hangup handler CHANNEL(name)='${CHANNEL(name)}' SIPCALLID='${SIPCALLID}')</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Set(CHANNEL(hangup_handler_push)=test_callee_hangup,${EXTEN},1)</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Dumpchan</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Return</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">[test_caller_hangup]</font></div><div class="gmail_default"><font face="monospace, monospace">exten => _X.,1,Noop(#### Running callER hangup handler CHANNEL(name)='${CHANNEL(name)}' SIPCALLID='${SIPCALLID}')</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Dumpchan</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Return</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">[test_callee_hangup]</font></div><div class="gmail_default"><font face="monospace, monospace">exten => _X.,1,Noop(#### Running callEE hangup handler CHANNEL(name)='${CHANNEL(name)}' SIPCALLID='${SIPCALLID}')</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Dumpchan</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Return</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">[test_intercept_callee]</font></div><div class="gmail_default"><font face="monospace, monospace">exten => _X.,1,Noop(### Running post Dial() dialplan on callEE CHANNEL(name)='${CHANNEL(name)}' SIPCALLID='${SIPCALLID}')</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Dumpchan</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,ExecIf($["${DIALSTATUS}" == "ANSWER"]?Hangup)</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Busy)</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Hangup</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">[test_intercept_caller]</font></div><div class="gmail_default"><font face="monospace, monospace">exten => _X.,1,Noop(### Running post Dial() dialplan on callER CHANNEL(name)='${CHANNEL(name)}' SIPCALLID='${SIPCALLID}')</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Dumpchan</font></div><div class="gmail_default"><font face="monospace, monospace"> same => n,Hangup</font></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace"></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 6, 2018 at 2:37 PM, David P <span dir="ltr"><<a href="mailto:davidswalkabout@gmail.com" target="_blank">davidswalkabout@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">FYI, we found that our peers don't hangup properly. But we would still like to know how to get the peer's hangup handler to fire upon peer hangup, because right now it corrupts our globals by firing after the caller's hangup handler.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 5, 2018 at 5:40 PM, David P <span dir="ltr"><<a href="mailto:davidswalkabout@gmail.com" target="_blank">davidswalkabout@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">FWIW, I added the following after the Dial, and it doesn't appear in cli after peer hangup:<div><br></div><div>same => n,NoOp(After Dial ${AddressToReachPeer})<br></div><div><br></div><div>I also tried putting 'g' before the 'b'.</div><div><br></div><div>I also tried removing the context headers of the hangup handlers and predial handler, and just referring to those by extensions. No difference.</div></div><div class="m_624753502760033333HOEnZb"><div class="m_624753502760033333h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 5, 2018 at 3:17 PM, David P <span dir="ltr"><<a href="mailto:davidswalkabout@gmail.com" target="_blank">davidswalkabout@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This has been super-helpful, Eric. However, the
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">handleHangupByPeer</span> priorities below are still not run when the peer hangs-up. The last line in the cli when the peer hangs-up is still:<div>Strict RTP learning complete - Locking on source address</div><div>(Although sometimes there is also: Retransmission timeout reached on transmission)<br><div><br></div><div><div> same => n(callPeer),Set(GLOBAL(CB${Ind<wbr>exIntoPeers}CurrentCallsCount)<wbr>=$[${PeerCurrentCallsCount} + 1])</div><div> ; Ensure that hangup by caller/inbound-channel will invoke handleHangupByCaller.</div><div> same => n,Set(CHANNEL(hangup_handler_p<wbr>ush)=handleHangupByCaller,s,1(<wbr>args))</div><div> same => n,Set(AddressToReachPeer=SIP/$<wbr>{EXTEN:0:4}@${PeerBeingConside<wbr>red})</div><div> ; Ensure that the channel of the peer (i.e. outbound-channel) is configured with hangup handler.</div><div> same => n,Dial(${AddressToReachPeer},,<wbr>b(beforeDialingPeerConfigureIt<wbr>sChannelForPeerHangupHandling^<wbr>s^1))</div><div> same => n,Hangup</div><div> </div><div>[beforeDialingPeerConfigureIts<wbr>ChannelForPeerHangupHandling]</div><div>exten => s,1,Set(CHANNEL(hangup_handler<wbr>_push)=handleHangupByPeer,s,1(<wbr>args))</div><div> same => n,Return</div><div> </div><div>[handleHangupByPeer]</div><div> ; Ensure that GLOBAL(CB${IndexIntoPeers}Curr<wbr>entCallsCount) is decremented after hangup, and end-of-call-epoch is set.</div><div>exten => s,1,NoOp(${PeerBeingConsidered<wbr>} peer channel: Entered handleHangupByCallerOrPeer Calls ${CB${IndexIntoPeers}CurrentCa<wbr>llsCount})</div><div> same => n,Set(GLOBAL(CB${IndexIntoPeer<wbr>s}CurrentCallsCount)=$[${CB${I<wbr>ndexIntoPeers}CurrentCallsCoun<wbr>t} - 1])</div><span><div> same => n,Set(GLOBAL(${PeerBeingConsid<wbr>ered}EpochAtCallEnd)=${EPOCH})</div><div> same => n,Return</div><div> </div></span><div>[handleHangupByCaller]</div><div> ; Ensure that GLOBAL(CB${IndexIntoPeers}Curr<wbr>entCallsCount) is decremented after hangup, and end-of-call-epoch is set.</div><div>exten => s,1,NoOp(${PeerBeingConsidered<wbr>} caller channel: Entered handleHangupByCallerOrPeer Calls ${CB${IndexIntoPeers}CurrentCa<wbr>llsCount})</div><div> same => n,Set(GLOBAL(CB${IndexIntoPeer<wbr>s}CurrentCallsCount)=$[${CB${I<wbr>ndexIntoPeers}CurrentCallsCoun<wbr>t} - 1])</div><span><div> same => n,Set(GLOBAL(${PeerBeingConsid<wbr>ered}EpochAtCallEnd)=${EPOCH})</div><div> same => n,Return</div></span></div><div><br></div><div><br></div><div>When the caller hangs-up, <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">handleHangupByCaller is run first, then <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">handleHangupByPeer runs. (And strangely, the value of global <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">CB${IndexIntoPeers}Curr<wbr>entCallsCount isn't accessible in
<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">handleHangupByPeer.</span>)</span></span></span></div><div><br></div><div>Cheers,</div><div>David</div><span><div><div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 5, 2018 at 12:58 PM, Eric Wieling <span dir="ltr"><<a href="mailto:ewieling@nyigc.com" target="_blank">ewieling@nyigc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Don't use the _. pattern. Ever.<br>
<br>
The call has two channels so it needs two hangup handlers, something like this, though I've not tested it.<br>
<br>
[some_context]<br>
exten => _X.,1,Noop<br>
same => n,Set(CHANNEL(hangup_handler_p<wbr>ush)=my_caller_hangup_handler)<br>
same => n,Dial(SIP/number@peer,b(pre_d<wbr>ial^s^1))<br>
same => n,Hangup<br>
<br>
[pre_dial]<br>
exten => s,1,Set(CHANNEL(hangup_handler<wbr>_push)=my_called_hangup_handle<wbr>r)<br>
same => Return<br>
<br>
See: <a href="https://wiki.asterisk.org/wiki/display/AST/Pre-Dial+Handlers" rel="noreferrer" target="_blank">https://wiki.asterisk.org/wiki<wbr>/display/AST/Pre-Dial+Handlers</a><br>
and <a href="https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers" rel="noreferrer" target="_blank">https://wiki.asterisk.org/wiki<wbr>/display/AST/Hangup+Handlers</a><span class="m_624753502760033333m_-8860210534177388803m_-6639619180952909318gmail-"><br>
<br></span></blockquote></div></div></div></div></span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
<br>-- <br>
______________________________<wbr>______________________________<wbr>_________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" rel="noreferrer" target="_blank">http://www.api-digital.com</a> --<br>
<br>
Check out the new Asterisk community forum at: <a href="https://community.asterisk.org/" rel="noreferrer" target="_blank">https://community.asterisk.<wbr>org/</a><br>
<br>
New to Asterisk? Start here:<br>
<a href="https://wiki.asterisk.org/wiki/display/AST/Getting+Started" rel="noreferrer" target="_blank">https://wiki.asterisk.org/<wbr>wiki/display/AST/Getting+<wbr>Started</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-users" rel="noreferrer" target="_blank">http://lists.digium.com/<wbr>mailman/listinfo/asterisk-<wbr>users</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><p><span style="font-size:12.8000001907349px">GMail: Making MS Outlook look good since 2007</span><br></p></div></div></div></div></div></div>
</div>