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

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…

If it works it’s good :slight_smile:
A few resources for you:
http://wiki.github.com/eventmachine/eventmachine/code-snippets
http://groups.google.com/group/eventmachine

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs