title: Socket.io: receive event triggering multiple times
body: <p>I'm trying to implement a simple lock using the following code:</p>
  
  <p>Server:</p>
  
  <pre><code>socket.on('lock', function(ressInfo) 
  {
    var lock = false;
    if(ressLocks.indexOf(ressInfo.id) === -1)
    {
      ressLocks.push(ressInfo.id);
      lock = true;
    }
    socket.emit("lock", lock);
  });
  </code></pre>
  
  <p>Client:</p>
  
  <pre><code>this.requestLock = function(ressInfo, callback)
  {
    if(currentlyOnline)
    {
      socket.emit("lock", ressInfo);
  
      socket.on("lock", function(lock) 
      {
        // this gets triggered one additional time with each lock
        callback(lock);
      });
    }
    else
    {
      callback(true);
    }
  }
  </code></pre>
  
  <p>On the first call I get one callback with <code>true</code>, on the second call I get two callbacks with <code>false</code>, on the third call three, etc.</p>
  
  <p>What is happening here? Why does <code>socket.on</code> get called multiple times?</p>