title: Can't emit from method defined outside of socket connection
body: <p>I'm trying to use a custom object's method to emit to a socket connection. The object is defined outside of the socket connection, but then instantiated inside of it. Code and error follows.</p>
  
  <h1>app.js</h1>
  
  <pre><code>...
  io.sockets.on('connection', function (socket) {
    report = new Report();
  
    socket.on('dataChange', function(newData) {
      report.update(newData);
    });
  });
  
  function Report () {
    this.update = function (data) {
      socket.emit('updateReport', { data: data });
    }
  }
  </code></pre>
  
  <h1>Error</h1>
  
  <p>Node gives me the following error.</p>
  
  <blockquote>
    <p>socket.emit('updateReport', { data: data });<br>
    ^</p>
    
    <p>ReferenceError: socket is not defined</p>
  </blockquote>