A simple chat server in Node.js(dhotson.tumblr.com)
dhotson.tumblr.com
A simple chat server in Node.js
http://dhotson.tumblr.com/post/271733389/a-simple-chat-server-in-node-js
3 comments
Doesn't node come with a built in chat server demo?
http://github.com/ry/node_chat
http://github.com/ry/node_chat
Yes, but that is designed for a browser/web/comet chat demo.
This chat demo is just a bare-bones tcp socket netcat/telnet chat server. Simple. Elegant. Effective.
This chat demo is just a bare-bones tcp socket netcat/telnet chat server. Simple. Elegant. Effective.
There's also an ircd
https://gist.github.com/a3d0bbbff196af633995
https://gist.github.com/a3d0bbbff196af633995
Very cool. One question:
Can you please explain this line?
Can you please explain this line?
55 if (c != client)For some context:
54 clients.each(function(c) {
55 if (c != client)
56 c.connection.send(client.name + ": " + data);
57 });
Line 55 is just there as a check to prevent echoing back the message to the client that sent it (as presumably the message they type will already be on their screen/terminal, if they are connected with netcat as the author suggests).This is correct. :-)
This is not needed. There's .forEach already.