mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
invoke callbacks if async handler is specified
This commit is contained in:
parent
a345089c8b
commit
7cec7ae608
@ -31,6 +31,7 @@ module.exports = function(RED) {
|
|||||||
node.data = [];
|
node.data = [];
|
||||||
node.msgQueue = [];
|
node.msgQueue = [];
|
||||||
node.closing = false;
|
node.closing = false;
|
||||||
|
node.closeCallbacks = [];
|
||||||
|
|
||||||
function processMsg(msg, done) {
|
function processMsg(msg, done) {
|
||||||
var filename = node.filename || msg.filename || "";
|
var filename = node.filename || msg.filename || "";
|
||||||
@ -180,10 +181,19 @@ module.exports = function(RED) {
|
|||||||
if (node.wstream) { node.wstream.end(); }
|
if (node.wstream) { node.wstream.end(); }
|
||||||
if (node.tout) { clearTimeout(node.tout); }
|
if (node.tout) { clearTimeout(node.tout); }
|
||||||
node.status({});
|
node.status({});
|
||||||
|
var callbacks = node.closeCallbacks;
|
||||||
|
node.closeCallbacks = [];
|
||||||
node.closing = false;
|
node.closing = false;
|
||||||
|
for (cb in callbacks) {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.on('close', function() {
|
this.on('close', function(arg1, arg2) {
|
||||||
|
var cb = arg2 ? arg2 : arg1;
|
||||||
|
if (cb) {
|
||||||
|
node.closeCallbacks.push(done);
|
||||||
|
}
|
||||||
if (node.closing) {
|
if (node.closing) {
|
||||||
// already closing
|
// already closing
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user