changed from this.con to this.stream

This commit is contained in:
brianc 2010-10-07 19:39:43 -05:00
parent 3933be9e0d
commit 6abac08c6e

View File

@ -26,12 +26,11 @@ var Client = function(config) {
sys.inherits(Client, EventEmitter);
Client.prototype.connect = function() {
var con = this.stream;
if(con.readyState == 'closed'){
con.connect(this.port, this.host);
if(this.stream.readyState == 'closed'){
this.stream.connect(this.port, this.host);
}
var self = this;
con.on('connect', function() {
this.stream.on('connect', function() {
var data = ['user',self.user,'database', self.database,NUL].join(NUL);
var dataBuffer = Buffer(data);
var fullBuffer = Buffer(8 + dataBuffer.length);
@ -44,9 +43,9 @@ Client.prototype.connect = function() {
fullBuffer[6] = 0;
fullBuffer[7] = 0;
fullBuffer.write(data,8);
con.write(fullBuffer);
this.stream.write(fullBuffer);
});
con.on('data', function(data) {
this.stream.on('data', function(data) {
var parser = new Parser(data);
var result = parser.parse();
result.forEach(function(msg) {
@ -54,12 +53,12 @@ Client.prototype.connect = function() {
self.emit(msg.name, msg);
});
});
this.con = con;
};
Client.prototype.disconnect = function() {
var terminationBuffer = new Buffer([UTF8.X,0,0,0,4]);
this.con.write(terminationBuffer);
this.stream.write(terminationBuffer);
};
Client.prototype.query = function() {