mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #2227 from node-red/node-done
Adds Done callback to Input event handler
This commit is contained in:
@@ -23,6 +23,7 @@ var Subflow;
|
||||
var Log;
|
||||
|
||||
var nodeCloseTimeout = 15000;
|
||||
var asyncMessageDelivery = true;
|
||||
|
||||
/**
|
||||
* This class represents a flow within the runtime. It is responsible for
|
||||
@@ -125,6 +126,7 @@ class Flow {
|
||||
var id;
|
||||
this.catchNodes = [];
|
||||
this.statusNodes = [];
|
||||
this.completeNodeMap = {};
|
||||
|
||||
var configNodes = Object.keys(this.flow.configs);
|
||||
var configNodeAttempts = {};
|
||||
@@ -228,7 +230,7 @@ class Flow {
|
||||
this.trace(" id | type | alias");
|
||||
this.trace("------------------|--------------|-----------------");
|
||||
}
|
||||
// Build the map of catch/status nodes.
|
||||
// Build the map of catch/status/complete nodes.
|
||||
for (id in this.activeNodes) {
|
||||
if (this.activeNodes.hasOwnProperty(id)) {
|
||||
node = this.activeNodes[id];
|
||||
@@ -237,6 +239,13 @@ class Flow {
|
||||
this.catchNodes.push(node);
|
||||
} else if (node.type === "status") {
|
||||
this.statusNodes.push(node);
|
||||
} else if (node.type === "complete") {
|
||||
if (node.scope) {
|
||||
node.scope.forEach(id => {
|
||||
this.completeNodeMap[id] = this.completeNodeMap[id] || [];
|
||||
this.completeNodeMap[id].push(node);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -516,6 +525,20 @@ class Flow {
|
||||
return handled;
|
||||
}
|
||||
|
||||
handleComplete(node,msg) {
|
||||
if (this.completeNodeMap[node.id]) {
|
||||
let toSend = msg;
|
||||
this.completeNodeMap[node.id].forEach((completeNode,index) => {
|
||||
toSend = redUtil.cloneMessage(msg);
|
||||
completeNode.receive(toSend);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
get asyncMessageDelivery() {
|
||||
return asyncMessageDelivery
|
||||
}
|
||||
|
||||
dump() {
|
||||
console.log("==================")
|
||||
console.log(this.TYPE, this.id);
|
||||
@@ -562,6 +585,7 @@ function stopNode(node,removed) {
|
||||
module.exports = {
|
||||
init: function(runtime) {
|
||||
nodeCloseTimeout = runtime.settings.nodeCloseTimeout || 15000;
|
||||
asyncMessageDelivery = !runtime.settings.runtimeSyncDelivery
|
||||
Log = runtime.log;
|
||||
Subflow = require("./Subflow");
|
||||
Subflow.init(runtime);
|
||||
|
@@ -729,6 +729,10 @@ module.exports = {
|
||||
updateFlow: updateFlow,
|
||||
removeFlow: removeFlow,
|
||||
disableFlow:null,
|
||||
enableFlow:null
|
||||
enableFlow:null,
|
||||
isDeliveryModeAsync: function() {
|
||||
// If settings is null, this is likely being run by unit tests
|
||||
return !settings || !settings.runtimeSyncDelivery
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user