title: Socket.io - TypeError: socket.in is not a function
body: <p>I made a simple app that uses socket.io for sending messages.         </p>
  
  <p>Here the <strong>server</strong> code piece:    </p>
  
  <pre><code>var io = require('socket.io')(http);
  
  io.on('connection', function(socket) {
    console.log('a user connected');
  
    socket.on('disconnect', function() {
      console.log('user disconnected');
    });
  
    socket.on('connect to room', function(rooms) {
      for (var i = 0; i &lt; rooms.length; i++) {
        socket.join(i);
        console.log('joined to room number ' + i);
      }
    });
  
    socket.on('chat message', function(id, msg) {
      console.log('message!');
      io.broadcast.to(id).emit('chat message', msg);
    });
  });
  </code></pre>
  
  <p>And here is the <strong>client</strong> code:    </p>
  
  <pre><code>var socket = io('http://localhost:8080');
  
  socket.on('connect', function(socket) {
    console.log('you have been connected!');
  });
  
  socket.on('chat message', function(msg) {
    console.log('message!');
    $('#messages').append(msg);
  });
  
  socket.emit('connect to room', [{
    {
      user.rooms
    }
  }]);
  
  if (e.which == 13 &amp;&amp; target.is('#message')) {
    var message_text = $('#message').val();
    socket.in(room.id).emit(message_text);
    $(#messages).append(message_text);
  }
  </code></pre>
  
  <p>(The room object is the current opened room)
  After I ran it I got an error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: socket.in is not a function</p>
  </blockquote>
  
  <p>Have any ideas? If you think that I wrote something wrong, feel free to say it <code>(for example x++ instead x += 1)</code>.</p>