<div dir="ltr"><a href="https://github.com/englercj/node-esl">https://github.com/englercj/node-esl</a> is modeled after standard FS esl libs and seems to implement full spec<div style>I faced some strange troubles with malformed UTF8 symbols in messages, but it works well and is fully async.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/22 Thomas Lee <span dir="ltr"><<a href="mailto:thomas.lee@octon.net" target="_blank">thomas.lee@octon.net</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
Please take a look.<br>
<br>
I'm using node.js and esl (<a href="https://github.com/shimaore/esl" target="_blank">https://github.com/shimaore/esl</a>)<br>
<br>
For example,<br>
--------------------------------------------------<br>
//<br>
// esl-test1.js<br>
//<br>
<br>
var esl = require('esl');<br>
var util = require('util');<br>
<br>
var audio_file = [];<br>
//<br>
// play and get digits<br>
// <min> <max> <tries> <timeout> <terminators> <file> <invalid_file><br>
<var_name> <regexp> <digit_timeout><br>
//<br>
audio_file[0]='1 1 3 5000 # sounds/mywav/0.wav';<br>
audio_file[1]='1 1 3 5000 # sounds/mywav/1.wav';<br>
audio_file[2]='1 1 3 5000 # sounds/mywav/2.wav';<br>
audio_file[3]='1 1 3 5000 # sounds/mywav/3.wav';<br>
audio_file[4]='1 1 3 5000 # sounds/mywav/4.wav';<br>
audio_file[5]='1 1 3 5000 # sounds/mywav/5.wav';<br>
audio_file[6]='1 1 3 5000 # sounds/mywav/6.wav';<br>
audio_file[7]='1 1 3 5000 # sounds/mywav/7.wav';<br>
audio_file[8]='1 1 3 5000 # sounds/mywav/8.wav';<br>
audio_file[9]='1 1 3 5000 # sounds/mywav/9.wav';<br>
audio_file[10]='1 1 3 5000 # sounds/mywav/10.wav';<br>
audio_file[11]='1 1 3 5000 # sounds/mywav/11.wav';<br>
audio_file[12]='1 1 3 5000 # sounds/mywav/12.wav';<br>
audio_file[13]='1 1 3 5000 # sounds/mywav/13.wav';<br>
<br>
var error3 = '1 1 3 5000 # sounds/mywav/error3.wav';<br>
var welcome = '1 1 3 5000 # sounds/mywav/hello.wav';<br>
<br>
<br>
var server = esl.createCallServer();<br>
//var server = esl.createClient();<br>
<br>
server.on('CONNECT', function(req, res) {<br>
<br>
var uri, channel_data, unique_id;<br>
<br>
channel_data = req.body;<br>
unique_id = channel_data['Unique-ID'];<br>
<br>
<br>
req.execute('answer');<br>
<br>
//req.execute('playback', 'sounds/mywav/hello.wav');<br>
<br>
//req.execute('play_and_get_digits', '2 5 3 7000 #<br>
sounds/mywav/hello.wav sounds/mywav/error3.wav myFoo \d+');<br>
req.execute('play_and_get_digits', welcome);<br>
<br>
req.on('DTMF', function(req) {<br>
<br>
//util.log('DTMF:'+util.inspect(req, null, null));<br>
<br>
var digit;<br>
var channel_data;<br>
channel_data = req.body;<br>
unique_id = channel_data['Unique-ID'];<br>
<br>
util.log('DTMF: unique_id='+unique_id);<br>
<br>
digit = channel_data['DTMF-Digit'];<br>
console.log('DTMF Received=' + digit);<br>
util.log('DTMF Received');<br>
if(digit==='#' || digit==='*'){<br>
<br>
req.execute('play_and_get_digits', error3);<br>
<br>
<br>
} else {<br>
<br>
var n = parseInt(digit);<br>
<br>
req.execute('play_and_get_digits', audio_file[n]);<br>
<br>
<br>
}<br>
<br>
<br>
return;<br>
});<br>
<br>
req.on('CHANNEL_ANSWER', function(req) {<br>
<br>
//util.log('CHANNEL_ANSWER:'+util.inspect(req, null, null));<br>
var channel_data;<br>
channel_data = req.body;<br>
unique_id = channel_data['Unique-ID'];<br>
<br>
util.log('CHANNEL_ANSWER: unique_id='+unique_id);<br>
<br>
return util.log('Call was answered');<br>
});<br>
<br>
req.on('CHANNEL_HANGUP', function(req) {<br>
<br>
//util.log('CHANNEL_HANGUP:'+util.inspect(req, null, null));<br>
var channel_data;<br>
channel_data = req.body;<br>
unique_id = channel_data['Unique-ID'];<br>
<br>
util.log('CHANNEL_HANGUP: unique_id='+unique_id);<br>
<br>
console.log('CHANNEL_HANGUP');<br>
return util.log('CHANNEL_HANGUP');<br>
});<br>
<br>
req.on('CHANNEL_HANGUP_COMPLETE', function(req) {<br>
<br>
///util.log('CHANNEL_HANGUP_COMPLETE:'+util.inspect(req,<br>
null, null));<br>
<br>
var channel_data;<br>
channel_data = req.body;<br>
unique_id = channel_data['Unique-ID'];<br>
<br>
util.log('CHANNEL_HANGUP_COMPLETE: unique_id='+unique_id);<br>
<br>
console.log('CHANNEL_HANGUP_COMPLETE');<br>
return util.log('CHANNEL_HANGUP_COMPLETE');<br>
});<br>
<br>
req.on('DISCONNECT', function(req) {<br>
<br>
//util.log('DISCONNECT:'+util.inspect(req, null, null));<br>
var channel_data;<br>
channel_data = req.body;<br>
unique_id = channel_data['Unique-ID'];<br>
<br>
util.log('DISCONNECT: unique_id='+unique_id);<br>
<br>
console.log('DISCONNECT');<br>
return util.log('DISCONNECT');<br>
})<br>
<br>
//util.log('CONNECT: req '+util.inspect(req, null, null));<br>
util.log('CONNECT: unique_id='+unique_id);<br>
<br>
return util.log('CONNECT received');<br>
<br>
});<br>
<br>
server.listen(9173);<br>
<br>
-----------------------------------------------<br>
<br>
Thanks<br>
<br>
Regards,<br>
Thomas Lee<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://freeswitch-users.2379917.n2.nabble.com/Node-JS-ESL-libraries-tp7590562p7590938.html" target="_blank">http://freeswitch-users.2379917.n2.nabble.com/Node-JS-ESL-libraries-tp7590562p7590938.html</a><br>
Sent from the freeswitch-users mailing list archive at Nabble.com.<br>
<div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Best regards,<br><br>Dmitry Sytchev,<br>IT Engineer
</div>