title: Socket.IO - How to replace event listener on client
body: <p>I am wondering if there is an option in <strong>Socket.IO</strong> client library for Node.js for replacing listener function for specific event.</p>
  
  <p>I have this simple function:</p>
  
  <pre><code>var Service = module.exports = function(address) {
      var _socket = require('socket.io-client')(address);
  
      this.connectAccount = function(account, callback) {
          _socket.on('account/connected', function (response) {
              callback(response.data, response.message);
          });
  
          _socket.emit('account/connect', account.getParameters());
      };
  }
  </code></pre>
  
  <p>The problem is, when I call function <code>connectAccount()</code> several times, all  anonymous functions I pass each time in <code>on()</code> function get also called and after short while it reaches the limit and throws error.</p>
  
  <p>So my question is if there is a way how to replace each time that listener so each time it gets called only once?</p>
  
  <p>Thanks in advance.</p>