[Eventmachine-talk] i wrote a chatroom server

Elliot Temple
2007-08-27T14:22:48Z

Hi,

I''m new to networking and wrote a simple chat server and client to
see how eventmachine works.

server: http://pastie.caboo.se/91452
client: http://pastie.caboo.se/91453

Notes:

supported commands: say something, change username, quit. it''s a
chat*room*: all users send their chat to everyone else. more features
(channels, private messages, etc) would be easy to add.

the client sends messages in the format (no commas):
command,separator,message,separator

so there is a "message" inside each "message". that was a
bad way to
name it.

overall this was easy!



I think I''m done working on it now since I don''t actually
intend to
use it. Any comments on coding style/approach mistakes would still be
appreciated. Also Francis mentioned wanting to have one good chat
server implementation to put in the eventmachine distro, I guess as a
code sample -- if you like mine but there are specific features/
changes it needs to be used I''d be open to adding them.


I plan to work on a boardgame program next w/ multiplayer via
eventmachine. One thing I''m not sure how to do yet is to use
eventmachine in the game loop. I think I''d like to be able to call
my_eventmachine_object.tick in the game loop to have eventmachine do
one iteration of it''s loop instead of having it loop constantly. but
maybe that''s the wrong approach.

-- Elliot Temple