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