clear response listeners after 2 seconds.
This commit is contained in:
parent
d70fa6d4a2
commit
0290d7f15f
|
@ -1383,13 +1383,20 @@ Program.prototype.response = function(name, text, callback) {
|
||||||
? 'response ' + name
|
? 'response ' + name
|
||||||
: 'response';
|
: 'response';
|
||||||
|
|
||||||
this.once(name, function(event) {
|
var onresponse;
|
||||||
|
|
||||||
|
this.once(name, onresponse = function(event) {
|
||||||
|
if (timeout) clearTimeout(timeout);
|
||||||
if (event.type === 'error') {
|
if (event.type === 'error') {
|
||||||
return callback(new Error(event.event + ': ' + event.text));
|
return callback(new Error(event.event + ': ' + event.text));
|
||||||
}
|
}
|
||||||
return callback(null, event);
|
return callback(null, event);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var timeout = setTimeout(function() {
|
||||||
|
self.removeListener(name, onresponse);
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
return this._write(text);
|
return this._write(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue