basic chat client using eventmachine

A

Angel Marques

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top