Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-07 Thread Diego Viola
Hi guys, It's me again, does anyone knows why this doesn't work? require 'rubygems' require 'eventmachine' require 'ESL' EventMachine.run { con = EventMachine::start_server 127.0.0.1, 8084 do fd = con.to_i esl = ESL::ESLconnection.new(fd)

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-07 Thread Mikael Aleksander Bjerkeland
EventMachine is very different to TCPSocket and is definitely not a drop-in replacement. Take a look at FreeSWITCHeR (http://code.rubyists.com/projects/fs/repository) and see how they implemented EventMachine. More info about EventMachine and specifically #start_server is here:

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-07 Thread Diego Viola
I see, but it should work with ESL too right? Diego On Thu, May 7, 2009 at 7:55 AM, Mikael Aleksander Bjerkeland mik...@bjerkeland.com wrote: EventMachine is very different to TCPSocket and is definitely not a drop-in replacement. Take a look at FreeSWITCHeR

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-07 Thread Diego Viola
Ok, this seems to work: require 'rubygems' require 'eventmachine' module CallingCard def post_init send_data sendmsg\ncall-command: execute\nexecute-app-name: answer\n\n send_data sendmsg\ncall-command: execute\nexecute-app-name: playback\nexecute-app-arg:

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-07 Thread Diego Viola
It seems like EM (EventMachine) can't be used with ESL. 16:41 diegoviola thedonvaughn: i see, so ESL itself can't be used with EM? 16:41 wyhaines You can't just hand the socket from EM to ESL. 16:42 thedonvaughn prolly not 16:42 thedonvaughn and if tmm1 doesn't know how, then i'm going to say

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-07 Thread Diego Viola
Hi guys, Nevermind with the ESL and EM thing. I was wondering what the getBody() getHeader() and other ESL stuff does behind the scenes, in raw socket, do you know? Thanks, Diego On Thu, May 7, 2009 at 4:44 PM, Diego Viola diego.vi...@gmail.com wrote: It seems like EM (EventMachine) can't be

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-07 Thread Jason White
Diego Viola diego.vi...@gmail.com wrote: Hi guys, Nevermind with the ESL and EM thing. I was wondering what the getBody() getHeader() and other ESL stuff does behind the scenes, in raw socket, do you know? Why not read the source code? This is free software and open-source, after all.

[Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Guido Kuth
Hello Diego, I don't know ruby but I was playing around with outbound socket as well. You have to start your TCPServer and then listen for connections on port 8084 (if you want it like it is standard). If the TCPServer gets a connect request from FS you have to Accept the connection. In .NET

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Diego Viola
Yep, it works Guido. require 'socket' server = TCPServer.new(8084) loop do con = server.accept con.puts connect\n\n con.puts sendmsg\ncall-command: execute\nexecute-app-name: answer\n\n con.puts sendmsg\ncall-command: execute\nexecute-app-name:

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Brian West
This is how we do it in perl with ESL... it should be very similar in Ruby. You shouldn't have to manually use sendmsg if you tie the fd from the socket to ESL like we do in perl. /b require ESL; use IO::Socket::INET; my $ip = 127.0.0.1; my $sock = new IO::Socket::INET ( LocalHost = $ip,

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Diego Viola
I tried to use ESL::ESLconnection in ruby but I get this. [di...@localhost ruby]$ ruby test.rb test.rb:7:in `initialize': Wrong arguments for overloaded method 'ESLconnection.new'. (ArgumentError) Possible C/C++ prototypes are: ESLconnection.new(char const *host, char const *port, char const

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Diego Viola
Do I need to do something with the file descriptor or fileno first? Sorry, I don't know perl. Diego On Sun, May 3, 2009 at 5:17 PM, Diego Viola diego.vi...@gmail.com wrote: I tried to use ESL::ESLconnection in ruby but I get this. [di...@localhost ruby]$ ruby test.rb test.rb:7:in

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Brian West
You have to pass it the file descriptor I suspect like we do in perl, python and lua. /b On May 3, 2009, at 4:17 PM, Diego Viola wrote: esl = ESL::ESLconnection.new(con) Brian West br...@freeswitch.org -- Meet us at ClueCon! http://www.cluecon.com

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Diego Viola
Ok, I'll try that. Thanks. Diego On Sun, May 3, 2009 at 5:25 PM, Brian West br...@freeswitch.org wrote: You have to pass it the file descriptor I suspect like we do in perl, python and lua. /b On May 3, 2009, at 4:17 PM, Diego Viola wrote: esl = ESL::ESLconnection.new(con) Brian West

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Brian West
What ever the equiv. function in ruby is. /b On May 3, 2009, at 4:26 PM, Diego Viola wrote: Do I need to do something with the file descriptor or fileno first? Sorry, I don't know perl. Diego Brian West br...@freeswitch.org -- Meet us at ClueCon! http://www.cluecon.com

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Brian West
I think its con.fileno in this case? Not sure. /b On May 3, 2009, at 4:00 PM, Diego Viola wrote: Yep, it works Guido. require 'socket' server = TCPServer.new(8084) loop do con = server.accept con.puts connect\n\n con.puts sendmsg\ncall-command:

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Diego Viola
NICE! It works, it works =D require 'socket' require 'ESL' server = TCPServer.new(8084) loop do con = server.accept fd = con.to_i esl = ESL::ESLconnection.new(fd) esl.execute('answer') esl.execute('playback', 'tone_stream://%(1,0,350,440)') end Thanks everyone :D Diego On Sun, May 3, 2009

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Diego Viola
Will post some examples on the wiki now :) Diego On Sun, May 3, 2009 at 5:32 PM, Diego Viola diego.vi...@gmail.com wrote: NICE! It works, it works =D require 'socket' require 'ESL' server = TCPServer.new(8084) loop do con = server.accept fd = con.to_i esl = ESL::ESLconnection.new(fd)

Re: [Freeswitch-users] Re-2: Ruby and ESL help

2009-05-03 Thread Diego Viola
http://wiki.freeswitch.org/wiki/Event_Socket_Library#Ruby_Example Added. On Sun, May 3, 2009 at 5:33 PM, Diego Viola diego.vi...@gmail.com wrote: Will post some examples on the wiki now :) Diego On Sun, May 3, 2009 at 5:32 PM, Diego Viola diego.vi...@gmail.com wrote: NICE! It works, it