mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Refactor Subflow logic into own class
This commit is contained in:
@@ -35,6 +35,9 @@ function Node(n) {
|
||||
if (n._alias) {
|
||||
this._alias = n._alias;
|
||||
}
|
||||
if (n._flow) {
|
||||
this._flow = n._flow;
|
||||
}
|
||||
this.updateWires(n.wires);
|
||||
}
|
||||
|
||||
@@ -131,10 +134,12 @@ Node.prototype.send = function(msg) {
|
||||
msg._msgid = redUtil.generateId();
|
||||
}
|
||||
this.metric("send",msg);
|
||||
node = flows.get(this._wire);
|
||||
node = this._flow.getNode(this._wire);
|
||||
/* istanbul ignore else */
|
||||
if (node) {
|
||||
node.receive(msg);
|
||||
} else {
|
||||
console.log("trying to send to a node not on this flow",this._wire);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
@@ -163,7 +168,7 @@ Node.prototype.send = function(msg) {
|
||||
var k = 0;
|
||||
// for each recipent node of that output
|
||||
for (var j = 0; j < wires.length; j++) {
|
||||
node = flows.get(wires[j]); // node at end of wire j
|
||||
node = this._flow.getNode(wires[j]); // node at end of wire j
|
||||
if (node) {
|
||||
// for each msg to send eg. [[m1, m2, ...], ...]
|
||||
for (k = 0; k < msgs.length; k++) {
|
||||
@@ -182,6 +187,8 @@ Node.prototype.send = function(msg) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log("trying to send to a node not on this flow",this._wire);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,7 +258,7 @@ Node.prototype.error = function(logMessage,msg) {
|
||||
}
|
||||
var handled = false;
|
||||
if (msg) {
|
||||
handled = flows.handleError(this,logMessage,msg);
|
||||
handled = this._flow.handleError(this,logMessage,msg);
|
||||
}
|
||||
if (!handled) {
|
||||
log_helper(this, Log.ERROR, logMessage);
|
||||
@@ -286,6 +293,6 @@ Node.prototype.metric = function(eventname, msg, metricValue) {
|
||||
* status: { fill:"red|green", shape:"dot|ring", text:"blah" }
|
||||
*/
|
||||
Node.prototype.status = function(status) {
|
||||
flows.handleStatus(this,status);
|
||||
this._flow.handleStatus(this,status);
|
||||
};
|
||||
module.exports = Node;
|
||||
|
||||
Reference in New Issue
Block a user