title: SocketIO - How to send data to a specific client
body: <p>I'm having a problem sending data to a specific client. </p>
  
  <p>Serverside</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var io = require('socket.io').listen(app.listen(app.get('port')));
  
  io.sockets.on('connection', function (socket) {
  
      socket.on('onHabboConnection', function (data) {
        socket.id = data.id; 
        socket.join(data.id);
        io.sockets.in(data.id).emit('onHabboConnected');
      });
      
      socket.on('onHabboConnected', function (data) {
        console.log("&lt;" + socket.id + "&gt; " + data.username + " has joined the game.");
      });
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Clientside</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>   var socket = io.connect('http://localhost:3000');
                 $( document ).ready(function() {
     socket.emit('onHabboConnection', { id:'&lt;%= user.id %&gt;' });
    });
  
     socket.on('onHabboConnected', function () {
      console.log("WORKING" );
      socket.emit('onHabboConnected', { username: '&lt;%= user.username %&gt;'});
     });</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  io.sockets.in(data.id).emit('onHabboConnected');</code></pre>
  </div>
  </div>
  </p>
  
  <p>I've attempted all over methods but they all throw errors.
  This one doesn't throw an error but doesn't do anything!</p>