[Freeswitch-users] Javascript Outbound Event Socket - Linger Command

Michael Collins msc at freeswitch.org
Mon May 7 06:14:14 MSD 2012


Hi Sara,

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:

 esl_send_recv(&handle, "linger");

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:

req.send_recv("linger");

Could you give that a try and let us know if it works? If it does we'd
appreciate you updating the wiki. :)

Thanks,
MC

On Sat, May 5, 2012 at 12:54 PM, Sara Higfler <sarahig1985 at gmail.com> wrote:

> Hi,
>
> 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.
>
> Kind regards.
>
> (function()
> {
>         var server, esl;
>
>         esl = require('esl');
>         util = require('util');
>
>         server = esl.createCallServer();
>
>  server.on('CONNECT', function(req, res)
>  {
>          var uri, channel_data, unique_id;
>
>          channel_data = req.body;
>          unique_id = channel_data['Unique-ID'];
>
>          req.execute('answer');
>
>          req.execute('playback', 'hello.wav');
>
>                 req.on('DTMF', function(req)
>                 {
>                         var digit;
>                         var channel_data;
>                         channel_data = req.body;
>
>                         digit = channel_data['DTMF-Digit'];
>                         console.log('DTMF Received=' + digit);
>                         return util.log('DTMF Received');
>                 });
>
>                 req.on('CHANNEL_ANSWER', function(req)
>                 {
>                         return util.log('Call was answered');
>                 });
>
>                 req.on('CHANNEL_HANGUP', function(req)
>                 {
>                         console.log('CHANNEL_HANGUP');
>                         return util.log('CHANNEL_HANGUP');
>                 });
>                 req.on('CHANNEL_HANGUP_COMPLETE', function(req)
>                 {
>                         console.log('CHANNEL_HANGUP_COMPLETE');
>                         return util.log('CHANNEL_HANGUP_COMPLETE');
>                 });
>
>                 req.on('DISCONNECT', function(req)
>                 {
>                          console.log('DISCONNECT');
>                          return util.log('DISCONNECT');
>                 })
>
>       });
>       return util.log('CONNECT received');
>  });
>
>  server.listen(9123);
> }).call(this);
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120506/7e535570/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list