Skip to content

Commit

Permalink
fix QUIT processing with flood protection
Browse files Browse the repository at this point in the history
Closes #138.
  • Loading branch information
Fionn Kelleher committed May 29, 2014
1 parent f8e6b65 commit 574f2b0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/irc.js
Expand Up @@ -699,7 +699,14 @@ Client.prototype.disconnect = function ( message, callback ) { // {{{
message = message || "node-irc says goodbye";
var self = this;
if ( self.conn.readyState == 'open' ) {
self.send( "QUIT", message );
var sendFunction;
if (self.opt.floodProtection) {
sendFunction = self._sendImmediate;
self._clearCmdQueue();
} else {
sendFunction = self.send;
}
sendFunction.call(self, "QUIT", message);
}
self.conn.requestedDisconnect = true;
if (typeof(callback) === 'function') {
Expand Down Expand Up @@ -737,6 +744,14 @@ Client.prototype.activateFloodProtection = function(interval) { // {{{
cmdQueue.push(arguments);
};

this._sendImmediate = function () {
origSend.apply(self, arguments);
}

this._clearCmdQueue = function () {
cmdQueue = [];
}

dequeue = function() {
var args = cmdQueue.shift();
if (args) {
Expand All @@ -750,6 +765,7 @@ Client.prototype.activateFloodProtection = function(interval) { // {{{


}; // }}}

Client.prototype.join = function(channel, callback) { // {{{
var channelName = channel.split(' ')[0];
this.once('join' + channelName, function () {
Expand Down

0 comments on commit 574f2b0

Please sign in to comment.