<div>Hi Michael,</div><div> </div><div>Thanks for your feedback - I&#39;m glad that I hadn&#39;t missed anything obvious via google.    I think I&#39;ve made good progress with this issue today.  It seems I can use either of the following to fire the linger command:</div>
<div>       req.linger();<br>       req.send(&quot;linger&quot;);</div><div> </div><div>Within the node debug logs I see the following, which confirms the request was successful.</div><div><br>        7 May 12:55:44 - on_data(Content-Type: command/reply<br>
        Reply-Text: +OK<br> <br>        Content-Type: command/reply<br>        Reply-Text: +OK will linger 600 seconds</div><div><br>What has really had me confused was which callback event to be expecting in the case of linger being invoked.  After further reviewing the partial examples I could find and looking at the debug traces, it seems I have to arm the callback on the &quot;esl_disconnect_notice&quot; event.  Within this callback, I need to check the content-dispostion header to determine if it is a disconnect or a linger.  I&#39;m using the following code today, which seems to pick up on every call termination.  It would be good if someone can confirm if I&#39;m cleaning up appropriately in the two cases (disconnect and linger).</div>
<div><br>        req.on(&#39;esl_disconnect_notice&#39;, function(req)<br>        {<br>                switch (req.headers[&#39;Content-Disposition&#39;])<br>                {<br>                        case &#39;disconnect&#39;:<br>
                                req.end();<br>                                break;<br>                         case &#39;linger&#39;:<br>                                req.exit();<br>                                break;<br>
                }</div><div>                console.log(&#39;esl_disconnect_notice:&#39;+req.headers[&#39;Content-Disposition&#39;]);<br>                return util.log(&#39;esl_disconnect_notice&#39;);<br>        });</div>
<div> </div><div>Thanks again!<br><br></div><div class="gmail_quote">On Mon, May 7, 2012 at 3:14 AM, Michael Collins <span dir="ltr">&lt;<a href="mailto:msc@freeswitch.org" target="_blank">msc@freeswitch.org</a>&gt;</span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">Hi Sara,<br><br>Welcome to FreeSWITCH. You are quite right - there is not documentation on how to send the linger command with an ESL application. I grep&#39;d around the libs/esl directory and found that fs_cli.c and esl.c have a function called esl_send_recv and a few occurrences of it used like this:<br>

<br><span style="font-family:courier new,monospace"> esl_send_recv(&amp;handle, &quot;linger&quot;);</span><br style="font-family:courier new,monospace"><br>I&#39;m no Javascript person but if I understand the syntax correctly you&#39;d need to do something like this as soon as the call is connected, i.e. right before the req.execute(&quot;answer&quot;) line:<br>

<br><span style="font-family:courier new,monospace">req.send_recv(&quot;linger&quot;);</span><br><br>Could you give that a try and let us know if it works? If it does we&#39;d appreciate you updating the wiki. :)<br><br>
Thanks,<br>
MC<br><br><div class="gmail_quote"><div><div class="h5">On Sat, May 5, 2012 at 12:54 PM, Sara Higfler <span dir="ltr">&lt;<a href="mailto:sarahig1985@gmail.com" target="_blank">sarahig1985@gmail.com</a>&gt;</span> wrote:<br>
</div></div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><div><div class="h5">
<div>Hi,</div><div> </div><div>I&#39;m a newbie to developing an outbound event handler for Freeswitch.  I&#39;m looking to use the Javascript ESL implemention (using node.js) and have managed to get basic scenarios working, including digit collection and checking against a MySQL database.  One problem I have is the capture of call termination events in my script.  Having read around a lot, I know that I&#39;m meant to use the Linger command, but cannot find any examples of how to do this with a Javascript outbound handler.  I&#39;ve included the rough structure of my code below (details removed for brevity) - I would really appreciate if someone could help show me how I would implement the linger command to ensure I capture all call termination events.</div>


<div> </div><div>Kind regards.</div><div> </div><div>(function()<br>{<br>        var server, esl;</div><div><br>        esl = require(&#39;esl&#39;);<br>        util = require(&#39;util&#39;);</div><div><br>        server = esl.createCallServer();</div>


<div><br> server.on(&#39;CONNECT&#39;, function(req, res)<br> {<br>         var uri, channel_data, unique_id;</div><div><br>         channel_data = req.body;</div><div>         unique_id = channel_data[&#39;Unique-ID&#39;];</div>


<div><br>         req.execute(&#39;answer&#39;);<br> <br>         req.execute(&#39;playback&#39;, &#39;hello.wav&#39;);</div><div> </div><div>                req.on(&#39;DTMF&#39;, function(req)<br>                {<br>                        var digit;<br>


                        var channel_data;<br>                        channel_data = req.body;</div><div><br>                        digit = channel_data[&#39;DTMF-Digit&#39;];<br>                        console.log(&#39;DTMF Received=&#39; + digit);</div>


<div>                        return util.log(&#39;DTMF Received&#39;);<br>                });</div><div> <br>                req.on(&#39;CHANNEL_ANSWER&#39;, function(req)<br>                {<br>                        return util.log(&#39;Call was answered&#39;);<br>


                });</div><div><br>                req.on(&#39;CHANNEL_HANGUP&#39;, function(req)<br>                {<br>                        console.log(&#39;CHANNEL_HANGUP&#39;);<br>                        return util.log(&#39;CHANNEL_HANGUP&#39;);<br>


                });</div><div>                req.on(&#39;CHANNEL_HANGUP_COMPLETE&#39;, function(req)<br>                {<br>                        console.log(&#39;CHANNEL_HANGUP_COMPLETE&#39;);<br>                        return util.log(&#39;CHANNEL_HANGUP_COMPLETE&#39;);<br>


                });</div><div><br>                req.on(&#39;DISCONNECT&#39;, function(req)</div><div>                {<br>                         console.log(&#39;DISCONNECT&#39;);<br>                         return util.log(&#39;DISCONNECT&#39;);<br>


                })</div><div><br>      });</div><div>      return util.log(&#39;CONNECT received&#39;);</div><div> });</div><div><br> server.listen(9123);</div><div>}).call(this);</div>
<br></div></div>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>