-
Notifications
You must be signed in to change notification settings - Fork 0
/
externaltask-output.js
32 lines (26 loc) · 1.17 KB
/
externaltask-output.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module.exports = function (RED) {
function ExternalTaskOutput(config) {
RED.nodes.createNode(this, config);
const node = this;
const flowContext = node.context().flow;
let eventEmitter = null;
node.on('input', function (msg) {
eventEmitter = flowContext.get('emitter');
if (!eventEmitter) {
flowContext.set('emitter', new EventEmitter());
eventEmitter = flowContext.get('emitter');
}
const flowNodeInstanceId = msg.flowNodeInstanceId;
const processInstanceId = msg.processInstanceId;
if (!flowNodeInstanceId) {
node.error('Error: The message did not contain the required external task id.', msg);
} else {
node.log(
`handle-${flowNodeInstanceId}: *flowNodeInstanceId* '${flowNodeInstanceId}' and *processInstanceId* '${processInstanceId}' with *msg._msgid* '${msg._msgid}'`,
);
}
eventEmitter.emit(`handle-${flowNodeInstanceId}`, msg, false);
});
}
RED.nodes.registerType('externaltask-output', ExternalTaskOutput);
};