title: socket emit an event on http PUT
body: <p>I am using <code>expressjs</code>, <code>nedb</code>, and <code>socket.io</code>. Various (non-browser) clients are able to <code>PUT</code> new values into the db successfully. When that happens, I want a message emitted to all browsers connected to the server. I have the following code which is currently not sending a message back to the browser.</p>
  
  <pre><code>// on the server
  //***************************************************************
  
  // reachable to the world at http://server/foo
  // clients can PUT data into the db
  app.put('/foo', jsonParser, function(req, res, next) {
      if (!req.body) return res.sendStatus(400);
  
      db.insert(req.body, function (err, newDoc) {
          io.sockets.emit('PUT a new value', { added: newDoc._id });
          res.send('Success! Find it again with id: ' + newDoc._id);
      });
  });
  
  // reachable to the world at http://server/
  // browser shows a dashboard of events
  app.get('/', function(req, res, next) {
      // code to serve the dashboard here
  });
  
  io.sockets.on('connection', function (socket) {
      socket.on('foo', function (data) {
          io.sockets.emit('PUT a new value', data);
      })
  });
  
  
  // in the browser
  //***************************************************************
  
  var socket = io.connect('/');
  socket.on('PUT a new value', function (data) {
      console.log(data);
  });
  </code></pre>
  
  <p>Data get inserted into the db successfully from different non-browser clients, but the connected browser doesn't receive an update.</p>
  
  <p>What am I doing wrong?</p>