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

Diego Viola diego.viola at gmail.com
Sun May 3 14:17:10 PDT 2009


I tried to use ESL::ESLconnection in ruby but I get this.

[diego at 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 *password)
    ESLconnection.new(int socket)
        from test.rb:7:in `new'
        from test.rb:7
        from test.rb:5:in `loop'
        from test.rb:5
[diego at localhost ruby]$

I made something like this:

esl = ESL::ESLconnection.new(con)

Where con is the accepted socket... should that work? Or do I have to
specify host/port/password on the ESLconnection?

Thanks,

Diego

On Sun, May 3, 2009 at 5:06 PM, Brian West <brian at freeswitch.org> wrote:
> 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,  LocalPort => '8040',
>  Proto => 'tcp',  Listen => 1,  Reuse => 1 );
> die "Could not create socket: $!\n" unless $sock;
> for(;;) {
>   my $new_sock = $sock->accept();
>   my $pid = fork();
>   if ($pid) {
>     close($new_sock);
>     next;
>   }
>   my $host = $new_sock->sockhost();
>   my $fd = fileno($new_sock);
>
>   my $con = new ESL::ESLconnection($fd);
>   my $info = $con->getInfo();
>   print $info->serialize();
>   my $uuid = $info->getHeader("unique-id");
>   $con->execute("answer", "", $uuid);
>   $con->execute("playback", "/ram/swimp.raw", $uuid);
>   close($new_sock);
> }
>
>
> 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: execute\nexecute-app-name:
> answer\n\n"
>        con.puts "sendmsg\ncall-command: execute\nexecute-app-name:
> playback\nexecute-app-arg: tone_stream://%(10000,0,350,440)\n\n"
> end
>
> Thanks for the tip =D
>
> Brian West
> brian at freeswitch.org
> -- Meet us at ClueCon!  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
>
>




More information about the FreeSWITCH-users mailing list