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

Diego Viola diego.viola at gmail.com
Thu May 7 13:11:07 PDT 2009


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 at gmail.com> wrote:
> I see, but it should work with ESL too right?
>
> Diego
>
> On Thu, May 7, 2009 at 7:55 AM, Mikael Aleksander Bjerkeland
> <mikael at bjerkeland.com> wrote:
>> 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ó:
>>> 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 at gmail.com> wrote:
>>> > http://wiki.freeswitch.org/wiki/Event_Socket_Library#Ruby_Example
>>> >
>>> > Added.
>>> >
>>> > On Sun, May 3, 2009 at 5:33 PM, Diego Viola <diego.viola at gmail.com> wrote:
>>> >> Will post some examples on the wiki now :)
>>> >>
>>> >> Diego
>>> >>
>>> >> On Sun, May 3, 2009 at 5:32 PM, Diego Viola <diego.viola at 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)
>>> >>> 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 at freeswitch.org> wrote:
>>> >>>> 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 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
>>> >>>>
>>> >>>>
>>> >>>
>>> >>
>>> >
>>>
>>> _______________________________________________
>>> 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
>>
>>
>> _______________________________________________
>> 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