<div>Hi Michael,</div><div> </div><div>Thanks for your feedback - I'm glad that I hadn't missed anything obvious via google. I think I'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("linger");</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 "esl_disconnect_notice" event. Within this callback, I need to check the content-dispostion header to determine if it is a disconnect or a linger. I'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'm cleaning up appropriately in the two cases (disconnect and linger).</div>
<div><br> req.on('esl_disconnect_notice', function(req)<br> {<br> switch (req.headers['Content-Disposition'])<br> {<br> case 'disconnect':<br>
req.end();<br> break;<br> case 'linger':<br> req.exit();<br> break;<br>
}</div><div> console.log('esl_disconnect_notice:'+req.headers['Content-Disposition']);<br> return util.log('esl_disconnect_notice');<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"><<a href="mailto:msc@freeswitch.org" target="_blank">msc@freeswitch.org</a>></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'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"><div><div class="h5">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>
</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'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></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>