title: Sending messages to all browsers with socket io
body: <p>I am messing around with socket.io and node.js, and was wondering how to accomplish the following: I have a simple form that sends a text string to the server, and the server sends it back, and it gets appended to a div. what I would like to do is have that div update for all users in all browsers, currently it only updates the one that the message was sent from.</p>
  
  <p>code from app.js (node.js server) :</p>
  
  <pre><code>io.sockets.on('connection', function(socket) {
      socket.on('send_message', function(data) {
      data.message = data.message + ' yo&lt;br/&gt;';
      socket.emit('get_message',data);
      });
  }); 
  </code></pre>
  
  <p>code on client-side:</p>
  
  <pre><code>    &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
      &lt;script&gt;
      $(document).ready(function() {
      var socket = io.connect('http://localhost:3000');
  
      $('#sender').live('click',function() {
              var user_message = $('#message_box').val()
              socket.emit('send_message',{message: user_message});
      });
  
      socket.on('get_message', function(data) {
          $('#data').append(data.message);
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>and the html:</p>
  
  <pre><code>&lt;div id='data'&gt;&lt;/div&gt;
  &lt;input type='text' id='message_box' placeholder='send message'&gt;
  &lt;button id='sender'&gt;Send Message&lt;/button&gt;
  </code></pre>
  
  <p>what should I be doing to send messages to multiple browsers?</p>