basic chat client using eventmachine

Discussion in 'Ruby' started by Angel Marques, Aug 10, 2010.

  1. basic chat client using eventmachine (I AM A BIG NOOB)

    Hi everybody, I'm try use eventmachine for make a simple chat client..I
    did the server and works fine but now I wanna do a client, the problem
    is simple, I'm very noob and I don't know how send my data to server,
    actually I can receibe data using

    def receive_data(data)
    puts data
    end

    but I don't know how to send data...I've this

    very simple
    module Client


    def post_init

    send_msje
    end


    private
    def send_msje
    while 1
    print "# say: "
    msje=gets
    puts "you say #{msje}"

    send_data msje
    end
    end





    def receive_data(data)
    puts data
    end
    end

    EventMachine::run do
    EventMachine::connect "0.0.0.0", 8081, Client
    end


    is it good?...sorry I'm full noob and the few examples about clients
    using EM only send one data to server and close the conexion, I only did
    a ugly loop for keep the conexion, if someone can explain me a bit about
    this I appreciate it..

    sorry for my english
    --
    Posted via http://www.ruby-forum.com/.
    Angel Marques, Aug 10, 2010
    #1
    1. Advertising

  2. Angel Marques

    Roger Pack Guest

    Roger Pack, Aug 10, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Cooke [MSFT]
    Replies:
    0
    Views:
    347
    Jason Cooke [MSFT]
    Oct 3, 2003
  2. Jason Cooke [MSFT]
    Replies:
    0
    Views:
    294
    Jason Cooke [MSFT]
    Jan 30, 2004
  3. Jason Cooke [MSFT]
    Replies:
    0
    Views:
    295
    Jason Cooke [MSFT]
    Jul 1, 2004
  4. Replies:
    0
    Views:
    2,176
  5. Bigmac Turdsplash

    from 'socket' to 'eventmachine' http client.

    Bigmac Turdsplash, Jan 24, 2011, in forum: Ruby
    Replies:
    0
    Views:
    244
    Bigmac Turdsplash
    Jan 24, 2011
Loading...

Share This Page