<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>