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">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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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>_________________________________________________________________________<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>