Just beginning to get a bit more advanced with our use of Freeswitch, and we'd like to start integrating it's internal data and status with the outside world a bit more. The idea was to listen in on the event socket and use that information to update an external data model. Looking at the wiki(http://wiki.freeswitch.org/wiki/Event_Socket#Javascript_.2F_Node.js_library), there seem to be 3 or 4 examples of how this is done, but I wondered if there's stuff that's not there or if one of these methods is proving more popular than the others. Any advice on where we should look first would be appreciated, cheers!
I don't have any specific examples in mind but I do recommend you check out the freeswitch-contrib repo. People have put a lot of interesting stuff in there. I know that intralaman has some ESL stuff in there that you might use as a reference. -MC On Fri, May 10, 2013 at 10:16 AM, Alex Lake <alex@digitalmail.com> wrote:
Just beginning to get a bit more advanced with our use of Freeswitch, and we'd like to start integrating it's internal data and status with the outside world a bit more.
The idea was to listen in on the event socket and use that information to update an external data model.
Looking at the wiki( http://wiki.freeswitch.org/wiki/Event_Socket#Javascript_.2F_Node.js_library ), there seem to be 3 or 4 examples of how this is done, but I wondered if there's stuff that's not there or if one of these methods is proving more popular than the others.
Any advice on where we should look first would be appreciated, cheers!
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Hi, Please take a look. I'm using node.js and esl (https://github.com/shimaore/esl) For example, -------------------------------------------------- // // esl-test1.js // var esl = require('esl'); var util = require('util'); var audio_file = []; // // play and get digits // <min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> <digit_timeout> // audio_file[0]='1 1 3 5000 # sounds/mywav/0.wav'; audio_file[1]='1 1 3 5000 # sounds/mywav/1.wav'; audio_file[2]='1 1 3 5000 # sounds/mywav/2.wav'; audio_file[3]='1 1 3 5000 # sounds/mywav/3.wav'; audio_file[4]='1 1 3 5000 # sounds/mywav/4.wav'; audio_file[5]='1 1 3 5000 # sounds/mywav/5.wav'; audio_file[6]='1 1 3 5000 # sounds/mywav/6.wav'; audio_file[7]='1 1 3 5000 # sounds/mywav/7.wav'; audio_file[8]='1 1 3 5000 # sounds/mywav/8.wav'; audio_file[9]='1 1 3 5000 # sounds/mywav/9.wav'; audio_file[10]='1 1 3 5000 # sounds/mywav/10.wav'; audio_file[11]='1 1 3 5000 # sounds/mywav/11.wav'; audio_file[12]='1 1 3 5000 # sounds/mywav/12.wav'; audio_file[13]='1 1 3 5000 # sounds/mywav/13.wav'; var error3 = '1 1 3 5000 # sounds/mywav/error3.wav'; var welcome = '1 1 3 5000 # sounds/mywav/hello.wav'; var server = esl.createCallServer(); //var server = esl.createClient(); 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', 'sounds/mywav/hello.wav'); //req.execute('play_and_get_digits', '2 5 3 7000 # sounds/mywav/hello.wav sounds/mywav/error3.wav myFoo \d+'); req.execute('play_and_get_digits', welcome); req.on('DTMF', function(req) { //util.log('DTMF:'+util.inspect(req, null, null)); var digit; var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID']; util.log('DTMF: unique_id='+unique_id); digit = channel_data['DTMF-Digit']; console.log('DTMF Received=' + digit); util.log('DTMF Received'); if(digit==='#' || digit==='*'){ req.execute('play_and_get_digits', error3); } else { var n = parseInt(digit); req.execute('play_and_get_digits', audio_file[n]); } return; }); req.on('CHANNEL_ANSWER', function(req) { //util.log('CHANNEL_ANSWER:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID']; util.log('CHANNEL_ANSWER: unique_id='+unique_id); return util.log('Call was answered'); }); req.on('CHANNEL_HANGUP', function(req) { //util.log('CHANNEL_HANGUP:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID']; util.log('CHANNEL_HANGUP: unique_id='+unique_id); console.log('CHANNEL_HANGUP'); return util.log('CHANNEL_HANGUP'); }); req.on('CHANNEL_HANGUP_COMPLETE', function(req) { ///util.log('CHANNEL_HANGUP_COMPLETE:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID']; util.log('CHANNEL_HANGUP_COMPLETE: unique_id='+unique_id); console.log('CHANNEL_HANGUP_COMPLETE'); return util.log('CHANNEL_HANGUP_COMPLETE'); }); req.on('DISCONNECT', function(req) { //util.log('DISCONNECT:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID']; util.log('DISCONNECT: unique_id='+unique_id); console.log('DISCONNECT'); return util.log('DISCONNECT'); }) //util.log('CONNECT: req '+util.inspect(req, null, null)); util.log('CONNECT: unique_id='+unique_id); return util.log('CONNECT received'); }); server.listen(9173); ----------------------------------------------- Thanks Regards, Thomas Lee -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Node-JS-ESL-libraries-tp759056... Sent from the freeswitch-users mailing list archive at Nabble.com.
https://github.com/englercj/node-esl is modeled after standard FS esl libs and seems to implement full spec I faced some strange troubles with malformed UTF8 symbols in messages, but it works well and is fully async. 2013/5/22 Thomas Lee <thomas.lee@octon.net>
Hi,
Please take a look.
I'm using node.js and esl (https://github.com/shimaore/esl)
For example, -------------------------------------------------- // // esl-test1.js //
var esl = require('esl'); var util = require('util');
var audio_file = []; // // play and get digits // <min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> <digit_timeout> // audio_file[0]='1 1 3 5000 # sounds/mywav/0.wav'; audio_file[1]='1 1 3 5000 # sounds/mywav/1.wav'; audio_file[2]='1 1 3 5000 # sounds/mywav/2.wav'; audio_file[3]='1 1 3 5000 # sounds/mywav/3.wav'; audio_file[4]='1 1 3 5000 # sounds/mywav/4.wav'; audio_file[5]='1 1 3 5000 # sounds/mywav/5.wav'; audio_file[6]='1 1 3 5000 # sounds/mywav/6.wav'; audio_file[7]='1 1 3 5000 # sounds/mywav/7.wav'; audio_file[8]='1 1 3 5000 # sounds/mywav/8.wav'; audio_file[9]='1 1 3 5000 # sounds/mywav/9.wav'; audio_file[10]='1 1 3 5000 # sounds/mywav/10.wav'; audio_file[11]='1 1 3 5000 # sounds/mywav/11.wav'; audio_file[12]='1 1 3 5000 # sounds/mywav/12.wav'; audio_file[13]='1 1 3 5000 # sounds/mywav/13.wav';
var error3 = '1 1 3 5000 # sounds/mywav/error3.wav'; var welcome = '1 1 3 5000 # sounds/mywav/hello.wav';
var server = esl.createCallServer(); //var server = esl.createClient();
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', 'sounds/mywav/hello.wav');
//req.execute('play_and_get_digits', '2 5 3 7000 # sounds/mywav/hello.wav sounds/mywav/error3.wav myFoo \d+'); req.execute('play_and_get_digits', welcome);
req.on('DTMF', function(req) {
//util.log('DTMF:'+util.inspect(req, null, null));
var digit; var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('DTMF: unique_id='+unique_id);
digit = channel_data['DTMF-Digit']; console.log('DTMF Received=' + digit); util.log('DTMF Received'); if(digit==='#' || digit==='*'){
req.execute('play_and_get_digits', error3);
} else {
var n = parseInt(digit);
req.execute('play_and_get_digits', audio_file[n]);
}
return; });
req.on('CHANNEL_ANSWER', function(req) {
//util.log('CHANNEL_ANSWER:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('CHANNEL_ANSWER: unique_id='+unique_id);
return util.log('Call was answered'); });
req.on('CHANNEL_HANGUP', function(req) {
//util.log('CHANNEL_HANGUP:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('CHANNEL_HANGUP: unique_id='+unique_id);
console.log('CHANNEL_HANGUP'); return util.log('CHANNEL_HANGUP'); });
req.on('CHANNEL_HANGUP_COMPLETE', function(req) {
///util.log('CHANNEL_HANGUP_COMPLETE:'+util.inspect(req, null, null));
var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('CHANNEL_HANGUP_COMPLETE: unique_id='+unique_id);
console.log('CHANNEL_HANGUP_COMPLETE'); return util.log('CHANNEL_HANGUP_COMPLETE'); });
req.on('DISCONNECT', function(req) {
//util.log('DISCONNECT:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('DISCONNECT: unique_id='+unique_id);
console.log('DISCONNECT'); return util.log('DISCONNECT'); })
//util.log('CONNECT: req '+util.inspect(req, null, null)); util.log('CONNECT: unique_id='+unique_id);
return util.log('CONNECT received');
});
server.listen(9173);
-----------------------------------------------
Thanks
Regards, Thomas Lee
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Node-JS-ESL-libraries-tp759056... Sent from the freeswitch-users mailing list archive at Nabble.com.
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Best regards, Dmitry Sytchev, IT Engineer
Oh, that's useful, thanks.
Hi,
Please take a look.
I'm using node.js and esl (https://github.com/shimaore/esl)
For example, -------------------------------------------------- // // esl-test1.js //
var esl = require('esl'); var util = require('util');
var audio_file = []; // // play and get digits // <min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> <digit_timeout> // audio_file[0]='1 1 3 5000 # sounds/mywav/0.wav'; audio_file[1]='1 1 3 5000 # sounds/mywav/1.wav'; audio_file[2]='1 1 3 5000 # sounds/mywav/2.wav'; audio_file[3]='1 1 3 5000 # sounds/mywav/3.wav'; audio_file[4]='1 1 3 5000 # sounds/mywav/4.wav'; audio_file[5]='1 1 3 5000 # sounds/mywav/5.wav'; audio_file[6]='1 1 3 5000 # sounds/mywav/6.wav'; audio_file[7]='1 1 3 5000 # sounds/mywav/7.wav'; audio_file[8]='1 1 3 5000 # sounds/mywav/8.wav'; audio_file[9]='1 1 3 5000 # sounds/mywav/9.wav'; audio_file[10]='1 1 3 5000 # sounds/mywav/10.wav'; audio_file[11]='1 1 3 5000 # sounds/mywav/11.wav'; audio_file[12]='1 1 3 5000 # sounds/mywav/12.wav'; audio_file[13]='1 1 3 5000 # sounds/mywav/13.wav';
var error3 = '1 1 3 5000 # sounds/mywav/error3.wav'; var welcome = '1 1 3 5000 # sounds/mywav/hello.wav';
var server = esl.createCallServer(); //var server = esl.createClient();
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', 'sounds/mywav/hello.wav');
//req.execute('play_and_get_digits', '2 5 3 7000 # sounds/mywav/hello.wav sounds/mywav/error3.wav myFoo \d+'); req.execute('play_and_get_digits', welcome);
req.on('DTMF', function(req) {
//util.log('DTMF:'+util.inspect(req, null, null));
var digit; var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('DTMF: unique_id='+unique_id);
digit = channel_data['DTMF-Digit']; console.log('DTMF Received=' + digit); util.log('DTMF Received'); if(digit==='#' || digit==='*'){
req.execute('play_and_get_digits', error3);
} else {
var n = parseInt(digit);
req.execute('play_and_get_digits', audio_file[n]);
}
return; });
req.on('CHANNEL_ANSWER', function(req) {
//util.log('CHANNEL_ANSWER:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('CHANNEL_ANSWER: unique_id='+unique_id);
return util.log('Call was answered'); });
req.on('CHANNEL_HANGUP', function(req) {
//util.log('CHANNEL_HANGUP:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('CHANNEL_HANGUP: unique_id='+unique_id);
console.log('CHANNEL_HANGUP'); return util.log('CHANNEL_HANGUP'); });
req.on('CHANNEL_HANGUP_COMPLETE', function(req) {
///util.log('CHANNEL_HANGUP_COMPLETE:'+util.inspect(req, null, null));
var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('CHANNEL_HANGUP_COMPLETE: unique_id='+unique_id);
console.log('CHANNEL_HANGUP_COMPLETE'); return util.log('CHANNEL_HANGUP_COMPLETE'); });
req.on('DISCONNECT', function(req) {
//util.log('DISCONNECT:'+util.inspect(req, null, null)); var channel_data; channel_data = req.body; unique_id = channel_data['Unique-ID'];
util.log('DISCONNECT: unique_id='+unique_id);
console.log('DISCONNECT'); return util.log('DISCONNECT'); })
//util.log('CONNECT: req '+util.inspect(req, null, null)); util.log('CONNECT: unique_id='+unique_id);
return util.log('CONNECT received');
});
server.listen(9173);
-----------------------------------------------
Thanks
Regards, Thomas Lee
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Node-JS-ESL-libraries-tp759056... Sent from the freeswitch-users mailing list archive at Nabble.com.
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
----- No virus found in this message. Checked by AVG - www.avg.com Version: 2012.0.2242 / Virus Database: 3162/5844 - Release Date: 05/21/13
participants (4)
-
Alex Lake
-
Dmitry Sytchev
-
Michael Collins
-
Thomas Lee