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'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(&handle, "linger");</span><br style="font-family:courier new,monospace"><br>I'm no Javascript person but if I understand the syntax correctly you'd need to do something like this as soon as the call is connected, i.e. right before the req.execute("answer") line:<br>
<br><span style="font-family:courier new,monospace">req.send_recv("linger");</span><br><br>Could you give that a try and let us know if it works? If it does we'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"><<a href="mailto:sarahig1985@gmail.com" target="_blank">sarahig1985@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>Hi,</div><div> </div><div>I'm a newbie to developing an outbound event handler for Freeswitch. I'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'm meant to use the Linger command, but cannot find any examples of how to do this with a Javascript outbound handler. I'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('esl');<br> util = require('util');</div><div><br> server = esl.createCallServer();</div>
<div><br> server.on('CONNECT', function(req, res)<br> {<br> var uri, channel_data, unique_id;</div><div><br> channel_data = req.body;</div><div> unique_id = channel_data['Unique-ID'];</div>
<div><br> req.execute('answer');<br> <br> req.execute('playback', 'hello.wav');</div><div> </div><div> req.on('DTMF', function(req)<br> {<br> var digit;<br>
var channel_data;<br> channel_data = req.body;</div><div><br> digit = channel_data['DTMF-Digit'];<br> console.log('DTMF Received=' + digit);</div>
<div> return util.log('DTMF Received');<br> });</div><div> <br> req.on('CHANNEL_ANSWER', function(req)<br> {<br> return util.log('Call was answered');<br>
});</div><div><br> req.on('CHANNEL_HANGUP', function(req)<br> {<br> console.log('CHANNEL_HANGUP');<br> return util.log('CHANNEL_HANGUP');<br>
});</div><div> req.on('CHANNEL_HANGUP_COMPLETE', function(req)<br> {<br> console.log('CHANNEL_HANGUP_COMPLETE');<br> return util.log('CHANNEL_HANGUP_COMPLETE');<br>
});</div><div><br> req.on('DISCONNECT', function(req)</div><div> {<br> console.log('DISCONNECT');<br> return util.log('DISCONNECT');<br>
})</div><div><br> });</div><div> return util.log('CONNECT received');</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>