News for hackers. Stuff that matters.
Re:A simple chat server in Node.js by bham on Monday December 07, 2009 @01:09AM (#980816)

    Array.prototype.each
This is not needed. There's .forEach already.
Re:A simple chat server in Node.js by dhotson on Monday December 07, 2009 @02:09AM (#980862)
Oh right.. thanks!

For some reason, I had it stuck in my mind that forEach() passed the index rather than the element.

Re:A simple chat server in Node.js by JimBastard on Sunday December 06, 2009 @04:50PM (#980210)
Doesn't node come with a built in chat server demo?

http://github.com/ry/node_chat

Re:A simple chat server in Node.js by jazzychad on Sunday December 06, 2009 @04:59PM (#980221)
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.

Re:A simple chat server in Node.js by bham on Monday December 07, 2009 @01:10AM (#980819)
Re:A simple chat server in Node.js by zackattack on Sunday December 06, 2009 @03:12PM (#980082)
Very cool. One question:

Can you please explain this line?

  55       if (c != client)
Re:A simple chat server in Node.js by jazzychad on Sunday December 06, 2009 @03:49PM (#980145)
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).
Re:A simple chat server in Node.js by dhotson on Sunday December 06, 2009 @05:55PM (#980297)
This is correct. :-)