<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<base href="x-msg://2520/"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.apple-style-span
        {mso-style-name:apple-style-span;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="margin-left:.5in"><o:p>&nbsp;</o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">On 20/09/2012, at 3:59 PM, Noah Engelberth &lt;<a href="mailto:Noah@directlinkcomputers.com">Noah@directlinkcomputers.com</a>&gt; wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">I&#8217;ve been working on an interactive XMPP interface so users at my office can interact with the timeclock and queues by XMPP (in addition to IVR menu,
 which has been running just fine for quite a while before the XMPP interface).&nbsp; I&#8217;m using sendtodialplan=yes to handling the incoming unsolicited messages, and typically will have at least one point of interaction where Asterisk requests authentication from
 the user and then waits with XMPP_RECEIVE for the response.&nbsp; Asterisk then processes the reply and finishes out the &#8220;call&#8221; as expected, no problems there.&nbsp; However, I&#8217;m seeing some behavior that I don&#8217;t really expect after the call finishes.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">&nbsp;<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">After my call finishes, sendtodialplan triggers again one time for each message that was sent back (and caught by XMPP_RECEIVE) during the just completed
 call.&nbsp; I&#8217;ve avoided unwanted extra processing by using XMPP_RECEIVE on a short timeout to process incoming unsolicited messages, so the net effect of this extra trigger is one or more &#8220;XMPP calls&#8221; that trip the 1 second timeout on this XMPP_RECEIVE and then
 fall through and clean up.&nbsp; However, when I initially started setting this up, my expectation was that sendtodialplan would only trigger on messages that weren&#8217;t solicited.&nbsp;&nbsp;<o:p></o:p></span></p>
</div>
</div>
</blockquote>
<p class="MsoNormal" style="margin-left:.5in"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">What does your dialplan look like?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Are you using _.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p>&nbsp;</o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p>&nbsp;</o:p></p>
</div>
<div>
<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.5pt;padding:0in 0in 1.0pt 0in;margin-left:.5in;margin-right:0in">
<p class="MsoNormal" style="border:none;padding:0in">Matt Riddell<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">No pattern matching in this portion of the dialplan.&nbsp; A rough approximation/sanitized psuedocode of what the code winds up as is&#8230;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">[xmpp-incoming]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">exten =&gt; s,1,Verbose(5,incoming)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,Set(REPLY_TO=${MESSAGE(from)})<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,Set(REPLY_TO=${CUT(REPLY_TO,:,2)}) ; to cut off xmpp:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,Set(REPLY_TO=${CUT(REPLY_TO,/,1)}) ; to cut off /resource<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,Set(MSG=${JABBER_RECEIVE(asterisk-xmpp,${REPLY_TO},1)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,GotoIf($[${ISNULL(${MSG})}]?hangup,1:message,1)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">exten =&gt; message,1,Verbose(5,process message)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,Set(CMD=${CUT(MSG, ,1)})<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,Set(PIN=Retrieve PIN via ODBC function)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,JabberSend(asterisk-xmpp,${REPLY_TO},Please authenticate)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,Set(ENTERED_PIN=${JABBER_RECEIVE(asterisk-xmpp,${REPLY_TO},15)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,GotoIf($[${ISNULL(${ENTERED_PIN})}]?timeout,1)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">&#8230; check if the pin matches, kick them to invalid-user,1 if it doesn&#8217;t, or process their command if it does&#8230;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">exten =&gt; hangup,1,Verbose(5,let the message fallthrough because using Hangup() dorks up message receiving)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">exten =&gt; timeout,1,Verbose(5,no input on authentication)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">same =&gt; n,JabberSend(asterisk-xmpp,${REPLY_TO},Sorry, you timed out.&nbsp; If you still want to execute your command, please try again.)<o:p></o:p></span></p>
<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt;padding:0in 0in 1.0pt 0in">
<p class="MsoNormal" style="border:none;padding:0in"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">What I&#8217;m seeing 100% of the time is that as soon as the &#8220;call&#8221; from the initial message falls through the end and gets hung up by autofallthrough, then a &#8220;new
 call&#8221; executes for the incoming message from the prompted JABBER_RECEIVE in the message extension (when I&#8217;m asking for authentication code.&nbsp; I have one specific command that winds up prompting for input a second time, and both prompted messages spawn off new
 calls, in order received, one after the other, after the original call is cleaned up.&nbsp; By having the one second timeout on the JABBER_RECEIVE in the s extension that pulls incoming unsolicited messages off the stack, I keep the XMPP calls from stacking up
 and impacting performance, but it just seems like odd behavior.&nbsp; Especially that the incoming message will wait any amount of time and fire off exactly when the previous call ends.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Thank you,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Noah Engelberth<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">MetaLINK Technologies<o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>