title: Socket.io won't emit to a room
body: <p>I am trying to create a chat lobby where users can create a private room, and others can join through a uuid. This is built with node.js and socket.io, and it seems as if <code>io.to(room).emit('event', 'data')</code> and <code>io.sockets.to(room).emit('event', 'data')</code> <strong>do not work</strong>, while <code>io.emit('event', 'data')</code> works. My code can be found below:</p>
  <pre class="lang-js prettyprint-override"><code>io.sockets.on('connection', (socket) =&gt; {
    socket.on('createRoom', function(data) {
        let room = new Room(data).create();
  
        let id = room.data.uuid
        socket.join(id)
  
        io.to(id).emit('roomcreated', {data: data, msg: 'Room Created'}) //Does not work!
        io.emit('roomcreated', {data: data, msg: 'Room Created'}) //This Works
    });
  });
  </code></pre>