Skip to content

Commit

Permalink
removed nextticking
Browse files Browse the repository at this point in the history
  • Loading branch information
Ant Cosentino committed Aug 2, 2015
1 parent b8dbd4c commit 240d3e4
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/rcon.js
Expand Up @@ -63,10 +63,10 @@ function listen() {
}

function reset() {
this.client.end();
this.authenticated = false;
this.responseCallbacks = [];
this.commands = [];
if (this.client) this.client.end();
}

var net = require('net'),
Expand All @@ -86,10 +86,8 @@ var Rcon = function(options) {
this.commands = [];

if (options.connect) {
process.nextTick(function() {
connect.call(this);
listen.call(this);
});
connect.call(this);
listen.call(this);
}
};

Expand All @@ -108,17 +106,15 @@ Rcon.prototype.exec = function(command, callback) {
Rcon.prototype.connect = function() {
this.emit('connecting');
if (!this.client) {
process.nextTick(function() {
connect.call(this);
listen.call(this);
});
connect.call(this);
listen.call(this);
}
return this;
};

Rcon.prototype.close = function() {
this.emit('disconnecting');
if (this.client) process.nextTick(reset.bind(this));
if (this.client) this.client.end();
return this;
};

Expand Down

0 comments on commit 240d3e4

Please sign in to comment.