title: ( Socket.io ) One socket connection multiple rooms
body: <p>I'm having problems with socket.io.
  I try to create a single socket connection where this is connected to multiple rooms.</p>
  
  <p>This is my current code:</p>
  
  <pre><code>function JoinRoom(id){
     socket = io(domain);
  
     socket.on('connect', function (data) {
          console.log('Connected to ' + room);
          socket.emit('room', room);
     });
  
     socket.on('message', function (data) {
          console.log(data);
     });
  }
  </code></pre>
  
  <p>The problem is that if I remove the var <strong>socket.io(domain)</strong> function was not connected and do not receive data from the room.</p>
  
  <p>Example:</p>
  
  <pre><code>socket = io(domain);
  function JoinRoom(id){
  
     socket.on('connect', function (data) {
          console.log('Connected to ' + room);
          socket.emit('room', room);
     });
  
     socket.on('message', function (data) {
          console.log(data);
     });
  }
  </code></pre>
  
  <p>If I take the socket.io() function of the JoinRoom() function I do not receive messages message or anything. It does not work.
  What am I doing wrong? Any solution?</p>