title: node.js websocket chat to handle parallel colors
body: <p>I'm working on some project where I need some chat application. I decided to test some node.js/websocket version here: <a href="http://martinsikora.com/nodejs-and-websocket-simple-chat-tutorial" rel="nofollow">http://martinsikora.com/nodejs-and-websocket-simple-chat-tutorial</a></p>
  
  <p>everything works perfect, but as he mentions in the end of the tutorial:</p>
  
  <blockquote>
    <p>Node.js unlike Apache doesn't use processes for each connection.</p>
  </blockquote>
  
  <p>It means that after 7 users logged in, every hard coded color will be used and then it uses white color for username style.</p>
  
  <pre><code>// Array with some colors
  var colors = [ 'red', 'green', 'blue', 'magenta', 'purple', 'plum', 'orange' ];
  // ... in random order
  colors.sort(function(a,b) { return Math.random() &gt; 0.5; } );
  
   userName = htmlEntities(message.utf8Data);
   // get random color and send it back to the user
    userColor = colors.shift();
    connection.sendUTF(JSON.stringify({ type:'color', data: userColor }));
    console.log((new Date()) + ' User is known as: ' + userName
            + ' with ' + userColor + ' color.');
  </code></pre>
  
  <p>Is it somehow possible to allow two users to use the same color?
  Thanks</p>