[–] zackattack 16y ago ↗ Very cool. One question:Can you please explain this line? 55 if (c != client) [–] jazzychad 16y ago ↗ 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). [–] dhotson 16y ago ↗ This is correct. :-)
[–] jazzychad 16y ago ↗ 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). [–] dhotson 16y ago ↗ This is correct. :-)
[–] JimBastard 16y ago ↗ Doesn't node come with a built in chat server demo?http://github.com/ry/node_chat [–] jazzychad 16y ago ↗ 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. [–] bham 16y ago ↗ There's also an ircdhttps://gist.github.com/a3d0bbbff196af633995
[–] jazzychad 16y ago ↗ 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. [–] bham 16y ago ↗ There's also an ircdhttps://gist.github.com/a3d0bbbff196af633995
[–] bham 16y ago ↗ Array.prototype.each This is not needed. There's .forEach already. [–] dhotson 16y ago ↗ Oh right.. thanks!For some reason, I had it stuck in my mind that forEach() passed the index rather than the element.
[–] dhotson 16y ago ↗ Oh right.. thanks!For some reason, I had it stuck in my mind that forEach() passed the index rather than the element.
8 comments
[ 4.1 ms ] story [ 33.2 ms ] threadCan you please explain this line?
http://github.com/ry/node_chat
This chat demo is just a bare-bones tcp socket netcat/telnet chat server. Simple. Elegant. Effective.
https://gist.github.com/a3d0bbbff196af633995
For some reason, I had it stuck in my mind that forEach() passed the index rather than the element.