Adding end method to namedpipeinputchannel.

This commit is contained in:
Andre Rodrigues 2012-03-16 13:53:18 -07:00
Родитель 5618502cc8
Коммит 64b9bba353
1 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -22,6 +22,7 @@ exports = module.exports = NamedPipeInputChannel;
function NamedPipeInputChannel() { function NamedPipeInputChannel() {
this.closeOnRead = true; this.closeOnRead = true;
this.client = null;
} }
NamedPipeInputChannel.prototype.readInputChannel = function (name, parseXml, callback) { NamedPipeInputChannel.prototype.readInputChannel = function (name, parseXml, callback) {
@ -60,18 +61,23 @@ NamedPipeInputChannel.prototype.readInputChannel = function (name, parseXml, cal
}); });
}; };
NamedPipeInputChannel.prototype.end = function () {
this.client.end();
};
NamedPipeInputChannel.prototype._readData = function (name, callback) { NamedPipeInputChannel.prototype._readData = function (name, callback) {
var self = this; var self = this;
var client = net.connect(name);
client.on('data', function (data) { self.client = net.connect(name);
self.client.on('data', function (data) {
if (self.closeOnRead) { if (self.closeOnRead) {
client.end(); self.client.end();
} }
callback(undefined, data); callback(undefined, data);
}); });
client.on('error', function (error) { self.client.on('error', function (error) {
callback(error); callback(error);
}); });
}; };