title: Displaying cursor on every connected client in socket.io
body: <p>I am trying to display the mouse cursors of all the connected client screen on every client's screen. Something like this : <a href="http://www.moock.org/unity/clients/uCoop/uCoop.html" rel="nofollow">http://www.moock.org/unity/clients/uCoop/uCoop.html</a></p>
  
  <p>I am working on socket.io using node.js. 
  I tried drawing a circle on the cursor position on the screen using context.drawImage on  mousemove but the cursor remains on the screen even after the mouse moves away and clearing the screen makes it slow. So I think, drawing on a canvas is not a perfect solution, I just need to emit the information of mouse co-ordinates to the client somehow. But I don't know how.</p>
  
  <p>Client side code snippet:</p>
  
  <pre><code>socket.on('draw_cursor', function (data) {
    var line = data.line;
    context.beginPath();
    context.fillStyle = "#000000";
    context.arc(line[0].x*width, line[0].y*height, 10, 0, 2*Math.PI);
    context.fill();
    delay(2000);
  });
  
  function mainLoop() {
    if (mouse.move &amp;&amp; mouse.pos_prev) {
      // send line to to the server
      socket.emit('draw_cursor', { line: [ mouse.pos, mouse.pos_prev ] });
    }
  }
  </code></pre>
  
  <p>Server side code snippet:</p>
  
  <pre><code>socket.on('draw_cursor', function (data) {
    io.emit('draw_cursor', { line: data.line });
  });
  </code></pre>
  
  <p>Thanks
  Vinni</p>