title: socket.io - how to broadcast messages on a namespace?
body: <p>According to socket.io examples:</p>
  
  <blockquote>
    <p>To broadcast, simply add a <code>broadcast</code> flag to <code>emit</code> and <code>send</code> method calls. Broadcasting means sending a message to everyone else except for the socket that starts it.</p>
  </blockquote>
  
  <pre><code>var io = require('socket.io').listen(80);
  
  io.sockets.on('connection', function (socket) {
    socket.broadcast.emit('user connected');
  });
  </code></pre>
  
  <p>I tried to combine this with the new socket.io namsepace feature, so I got this:</p>
  
  <pre><code>var chat = ioserver.of('/chat');
  
  chat.on('connection', function (socket) {
        console.log('chat connection');   
        socket.on('message', function (msg) {
          console.log(msg);  
          chat.send(msg);
        });
    });
  </code></pre>
  
  <p>This works fine, everyone on the chat channel (and no other channels) gets the message. But the sender also gets it.
  So I tried to do the following:</p>
  
  <pre><code>chat.on('connection', function (socket) {
        console.log('chat connection');   
        socket.on('message', function (msg) {
          console.log(msg);  
          chat.broadcast.send(msg);
        });
    });
  </code></pre>
  
  <p>and got an Exception: 'Cannot call method 'send' of undefined.'
  Ok, so I thought, that broadcast is the feature of a single socket (it feels a bit weird though - how a single socket can brodacast to all other...).
   So I tried:</p>
  
  <pre><code>chat.on('connection', function (socket) {
        console.log('chat connection');   
        socket.on('message', function (msg) {
          console.log(msg);  
          socket.broadcast.send(msg);
        });
    });
  </code></pre>
  
  <p>but now it was even worse - no one received the message, not even the sender. Anyway, it was what I logically expected - one socket cannot broadcast something through itself. And no exceptions this time, so broadcast is defined for the socket.</p>
  
  <p>If I do:</p>
  
  <pre><code>chat.on('connection', function (socket) {
        console.log('chat connection');   
        socket.on('message', function (msg) {
          console.log(msg);  
          socket.send(msg);
        });
    });
  </code></pre>
  
  <p>then only the original sender gets the message, and that is again pretty logical - I used the 'send' of the client-related socket.</p>
  
  <p><strong>So the question is: what is the correct way to use the broadcast feature?</strong> </p>
  
  <p>Maybe the developer of socket.io made a mistake and added the broadcast feature to the wrong object (as I understand, it should be the feature of the namespace but now it is defined only for the socket)?</p>