title: Socket.io api inconsistency or how does it work?
body: <p>When I do:</p>
  
  <pre><code>socket.join('room');
  socket.to('room').emit('online');
  </code></pre>
  
  <p>the 'online'-event is never received on the client side.</p>
  
  <p>When I do:</p>
  
  <pre><code> socket.join('room');
   io.to('room').emit('online');
  </code></pre>
  
  <p>the 'online'-event is received on the client side.</p>
  
  <p>When I do:</p>
  
  <pre><code>socket.join('room', () =&gt; {
      socket.to('room').emit('online');
  });
  </code></pre>
  
  <p>the 'online'-event is never received on the client side.</p>
  
  <p>The docs state the following:</p>
  
  <p><a href="http://socket.io/docs/server-api/#socket#to(room:string):socket" rel="nofollow">http://socket.io/docs/server-api/#socket#to(room:string):socket</a></p>
  
  <p>If I read this the call to:</p>
  
  <pre><code>socket.to('room').emit('online');
  </code></pre>
  
  <p>should be emitted to the room.</p>
  
  <p>If I use the call:</p>
  
  <pre><code>socket.broadcast.to('room').emit('online');
  </code></pre>
  
  <p>the event should emit to the room except the socket.</p>
  
  <p>Now it looks like that:</p>
  
  <pre><code>socket.to('room').emit('online');
  </code></pre>
  
  <p>and</p>
  
  <pre><code>io.to('room').emit('online');
  </code></pre>
  
  <p>are different. But what I read from the docs I read that they are the same.</p>
  
  <p>Can someone explain the differences and why behave different?     </p>