Reputation: 55
Given the following parent-process code:
//SSO
this.sso = fork('./app/utils/SSOproxy.js', [], {
stdio: [0, 1, 2, 'ipc']
});
console.log(process);
console.log(this.sso);
//__handshake
this.sso.send({
opcode: 'ACK',
params: [],
ref: null
});
console.log('STEP_1');
process.prependOnceListener('message', ((msg) => {
if (msg.status) {
if ((msg.opcode === 'ACK') && (msg.params[0] === 'ok')) {
console.log('STEP_3');
}
}
}));
//__e.o.handshake
And child-process (SSOproxy.js) code:
process.on('message', ((msg) => {
switch (msg.opcode) {
//handshake
case 'ACK':
process.send({
opcode: 'ACK',
params: ['ok'],
ref: null
});
console.log('STEP_2');
break;
//Other paths...
}
));
In the log observed - STEP_1 is followed by STEP_2 but I never see STEP_3 because I can't for-the-life of me figure out how to get duplex communication for child/parent. How to achieve the same?
Upvotes: 0
Views: 69
Reputation: 6969
In your prependOnceListener
you have a condition for msg.status
but I don't see this anywhere in your SSOproxy.js
code.
This means your if will never evaluate true
Can you try adding a status
to your message:
process.send({
opcode:'ACK',
params:['ok'],
ref: null,
status: 'test1234'
});
Upvotes: 2