title: socket.io sending N messages when joining room N times
body: <p>When I join a room, and send a message, it sends only once, but if I leave the room and rejoin the same room, it sends the same message twice. The message gets duplicated the number of times i leave/join the room. I am properly leaving the room because I no longer receive messages when i have left the room.</p>
  
  <pre><code>io.on('connect', socket =&gt; {
    console.log('New client connected')
  
    socket.on('removeRoom', room =&gt; {
      socket.leave(room)
      socket.to(room).emit(room + '-newMessage', 'user has left room')
    })
  
    socket.on('joinRoom', room =&gt; {
      socket.join(room)
  
      socket.on(room + '-newMessage', data =&gt; {
        io.sockets.in(room).emit('recieveMessage', data)
      })
    })
  
    socket.on('disconnect', () =&gt; {
      console.log('user disconnected')
    })
  })
  </code></pre>