Skip to content

Commit

Permalink
added reset function to refresh socket after use
Browse files Browse the repository at this point in the history
  • Loading branch information
Ant Cosentino committed Aug 2, 2015
1 parent 862767a commit b8dbd4c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/rcon.js
Expand Up @@ -62,6 +62,13 @@ function listen() {
}.bind(this));
}

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

var net = require('net'),
EventEmitter = require('events').EventEmitter,
inherits = require('util').inherits,
Expand Down Expand Up @@ -111,7 +118,7 @@ Rcon.prototype.connect = function() {

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

Expand Down

0 comments on commit b8dbd4c

Please sign in to comment.