Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

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

Goto page 1, 2  Next
 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users
View previous topic :: View next topic  
Author Message
diego.viola at gmail.com
Guest





PostPosted: Sun May 03, 2009 4:01 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

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

On Sun, May 3, 2009 at 12:58 PM, Guido Kuth <gk@exram.de> wrote:
Quote:
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 this is TCPServer.Accept(). This Returns a TCPClient Object which represents a dedicated connection for this specific call. A new call creates a new TCPClient Object. After that you first have to send a Connect Message ("Connect\n\n") to FS. FS will answer immediately with all data belongig to the call.

If this all ist done you can send an Answer command and/or whatever you want.

Hope this helps...Guido

Btw.: If you find out how one can handle real blocked execution of commands I would like to know how. I tried to playback a long file and my problem was that FS answers immediately after FS accepts the command to play this file, but there is nothing that will ever give you a notice about the playback has ended, what is an unsolved problem for me.

-------- Original Message --------
Subject: Re: [Freeswitch-users] Ruby and ESL help (03-Mai-2009 2:23)
From:    Diego Viola <diego.viola@gmail.com>
To:      gk@exram.de

Quote:
I'm trying to do Event socket outbound btw.

On Sat, May 2, 2009 at 7:57 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
Hello everyone,

I was trying to test ESL with Ruby, and I made this:

"
require 'socket'
require 'ESL'

TCPServer.new('127.0.0.1', '8084')
con = ESL::ESLconnection.new('127.0.0.1', '8084', '')
con.execute('answer')
con.execute('playback',
'/usr/local/freeswitch/sounds/music/8000/suite-espanola-op-47-leyenda.wav')
"

I can connect from freeswitch with sync and async mode, but it doesn't
do anything more than that, it doesn't execute my answer or playback,
anyone knows what's wrong with it? I use the freeswitcher lib and it
works great, but I also want to try ESL.

Thanks,

Diego


_______________________________________________
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



_______________________________________________
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


_______________________________________________
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
Back to top
brian at freeswitch.org
Guest





PostPosted: Sun May 03, 2009 4:07 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

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(;Wink {
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:
Quote:
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@freeswitch.org (brian@freeswitch.org)



-- Meet us at ClueCon! http://www.cluecon.com
Back to top
diego.viola at gmail.com
Guest





PostPosted: Sun May 03, 2009 4:18 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

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

[diego@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@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@freeswitch.org> wrote:
Quote:
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(;Wink {
  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@freeswitch.org
-- Meet us at ClueCon!  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



_______________________________________________
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
Back to top
brian at freeswitch.org
Guest





PostPosted: Sun May 03, 2009 4:26 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

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:
Quote:

esl = ESL::ESLconnection.new(con)


Brian West
brian@freeswitch.org (brian@freeswitch.org)



-- Meet us at ClueCon! http://www.cluecon.com
Back to top
diego.viola at gmail.com
Guest





PostPosted: Sun May 03, 2009 4:26 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

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.viola@gmail.com> wrote:
Quote:
I tried to use ESL::ESLconnection in ruby but I get this.

[diego@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@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@freeswitch.org> wrote:
Quote:
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(;Wink {
  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@freeswitch.org
-- Meet us at ClueCon!  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




_______________________________________________
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
Back to top
diego.viola at gmail.com
Guest





PostPosted: Sun May 03, 2009 4:27 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

Ok, I'll try that. Thanks.

Diego

On Sun, May 3, 2009 at 5:25 PM, Brian West <brian@freeswitch.org> wrote:
Quote:
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
brian@freeswitch.org
-- Meet us at ClueCon!  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



_______________________________________________
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
Back to top
brian at freeswitch.org
Guest





PostPosted: Sun May 03, 2009 4:29 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

I think its con.fileno in this case? Not sure.

/b

On May 3, 2009, at 4:00 PM, Diego Viola wrote:
Quote:
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@freeswitch.org (brian@freeswitch.org)



-- Meet us at ClueCon! http://www.cluecon.com
Back to top
diego.viola at gmail.com
Guest





PostPosted: Sun May 03, 2009 4:33 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

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://%(10000,0,350,440)')
end

Thanks everyone Very Happy

Diego

On Sun, May 3, 2009 at 5:29 PM, Brian West <brian@freeswitch.org> wrote:
Quote:
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: 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@freeswitch.org
-- Meet us at ClueCon!  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



_______________________________________________
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
Back to top
diego.viola at gmail.com
Guest





PostPosted: Sun May 03, 2009 4:33 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

Will post some examples on the wiki now Smile

Diego

On Sun, May 3, 2009 at 5:32 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
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://%(10000,0,350,440)')
end

Thanks everyone Very Happy

Diego

On Sun, May 3, 2009 at 5:29 PM, Brian West <brian@freeswitch.org> wrote:
Quote:
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: 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@freeswitch.org
-- Meet us at ClueCon!  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




_______________________________________________
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
Back to top
brian at freeswitch.org
Guest





PostPosted: Sun May 03, 2009 4:36 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

What ever the equiv. function in ruby is.

/b

On May 3, 2009, at 4:26 PM, Diego Viola wrote:
Quote:
Do I need to do something with the file descriptor or fileno first?
Sorry, I don't know perl.

Diego


Brian West
brian@freeswitch.org (brian@freeswitch.org)



-- Meet us at ClueCon! http://www.cluecon.com
Back to top
diego.viola at gmail.com
Guest





PostPosted: Sun May 03, 2009 4:46 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

http://wiki.freeswitch.org/wiki/Event_Socket_Library#Ruby_Example

Added.

On Sun, May 3, 2009 at 5:33 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
Will post some examples on the wiki now Smile

Diego

On Sun, May 3, 2009 at 5:32 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
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://%(10000,0,350,440)')
end

Thanks everyone Very Happy

Diego

On Sun, May 3, 2009 at 5:29 PM, Brian West <brian@freeswitch.org> wrote:
Quote:
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: 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@freeswitch.org
-- Meet us at ClueCon!  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





_______________________________________________
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
Back to top
diego.viola at gmail.com
Guest





PostPosted: Thu May 07, 2009 1:12 am    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

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)
esl.execute('answer')
end
}

But using it with the normal TCPServer works? I'm trying to use ESL
with EventMachine, but it doesn't appear to work. Although it does
with the normal TCPServer.

Thanks,

On Sun, May 3, 2009 at 5:43 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
http://wiki.freeswitch.org/wiki/Event_Socket_Library#Ruby_Example

Added.

On Sun, May 3, 2009 at 5:33 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
Will post some examples on the wiki now Smile

Diego

On Sun, May 3, 2009 at 5:32 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
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://%(10000,0,350,440)')
end

Thanks everyone Very Happy

Diego

On Sun, May 3, 2009 at 5:29 PM, Brian West <brian@freeswitch.org> wrote:
Quote:
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: 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@freeswitch.org
-- Meet us at ClueCon!  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






_______________________________________________
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
Back to top
mikael at bjerkeland.com
Guest





PostPosted: Thu May 07, 2009 6:56 am    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

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:
http://eventmachine.rubyforge.org/EventMachine.html#M000385




El jue, 07-05-2009 a las 02:11 -0400, Diego Viola escribió:
Quote:
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)
esl.execute('answer')
end
}

But using it with the normal TCPServer works? I'm trying to use ESL
with EventMachine, but it doesn't appear to work. Although it does
with the normal TCPServer.

Thanks,

On Sun, May 3, 2009 at 5:43 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
http://wiki.freeswitch.org/wiki/Event_Socket_Library#Ruby_Example

Added.

On Sun, May 3, 2009 at 5:33 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
Will post some examples on the wiki now :)

Diego

On Sun, May 3, 2009 at 5:32 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
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://%(10000,0,350,440)')
end

Thanks everyone :D

Diego

On Sun, May 3, 2009 at 5:29 PM, Brian West <brian@freeswitch.org> wrote:
Quote:
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: 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@freeswitch.org
-- Meet us at ClueCon! 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






_______________________________________________
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


_______________________________________________
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
Back to top
diego.viola at gmail.com
Guest





PostPosted: Thu May 07, 2009 11:05 am    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

I see, but it should work with ESL too right?

Diego

On Thu, May 7, 2009 at 7:55 AM, Mikael Aleksander Bjerkeland
<mikael@bjerkeland.com> wrote:
Quote:
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:
http://eventmachine.rubyforge.org/EventMachine.html#M000385




El jue, 07-05-2009 a las 02:11 -0400, Diego Viola escribió:
Quote:
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)
                esl.execute('answer')
        end
}

But using it with the normal TCPServer works? I'm trying to use ESL
with EventMachine, but it doesn't appear to work. Although it does
with the normal TCPServer.

Thanks,

On Sun, May 3, 2009 at 5:43 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
http://wiki.freeswitch.org/wiki/Event_Socket_Library#Ruby_Example

Added.

On Sun, May 3, 2009 at 5:33 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
Will post some examples on the wiki now Smile

Diego

On Sun, May 3, 2009 at 5:32 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
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://%(10000,0,350,440)')
end

Thanks everyone Very Happy

Diego

On Sun, May 3, 2009 at 5:29 PM, Brian West <brian@freeswitch.org> wrote:
Quote:
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: 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@freeswitch.org
-- Meet us at ClueCon!  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






_______________________________________________
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


_______________________________________________
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


_______________________________________________
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
Back to top
diego.viola at gmail.com
Guest





PostPosted: Thu May 07, 2009 3:24 pm    Post subject: [Freeswitch-users] Re-2: Ruby and ESL help Reply with quote

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:
tone_stream://%(10000,0,350,440)\n\n"
end
end

EventMachine::run {
EventMachine::start_server "127.0.0.1", 8084, CallingCard
}

But what about ESL? :/

Diego

On Thu, May 7, 2009 at 12:03 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
I see, but it should work with ESL too right?

Diego

On Thu, May 7, 2009 at 7:55 AM, Mikael Aleksander Bjerkeland
<mikael@bjerkeland.com> wrote:
Quote:
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:
http://eventmachine.rubyforge.org/EventMachine.html#M000385




El jue, 07-05-2009 a las 02:11 -0400, Diego Viola escribió:
Quote:
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)
                esl.execute('answer')
        end
}

But using it with the normal TCPServer works? I'm trying to use ESL
with EventMachine, but it doesn't appear to work. Although it does
with the normal TCPServer.

Thanks,

On Sun, May 3, 2009 at 5:43 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
http://wiki.freeswitch.org/wiki/Event_Socket_Library#Ruby_Example

Added.

On Sun, May 3, 2009 at 5:33 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
Will post some examples on the wiki now Smile

Diego

On Sun, May 3, 2009 at 5:32 PM, Diego Viola <diego.viola@gmail.com> wrote:
Quote:
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://%(10000,0,350,440)')
end

Thanks everyone Very Happy

Diego

On Sun, May 3, 2009 at 5:29 PM, Brian West <brian@freeswitch.org> wrote:
Quote:
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: 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@freeswitch.org
-- Meet us at ClueCon!  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






_______________________________________________
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


_______________________________________________
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



_______________________________________________
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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services