M
M
Maxla932016-10-11 14:11:25
Node.js
Maxla93, 2016-10-11 14:11:25

How to implement communication between child and parent in Node.js?

Created a cluster and divided into 3 processes.
1 - main
2 and 3 (the so-called bots that must exchange information with the main process).
But, bots have to send many different messages that will be used in a bunch of functions of the main one.
But the message service accepts absolutely all messages (and not exactly what we need).
> It is necessary that the child sends a message with the result of the Name5 function to the main one and that the main one receives only the result of the Name5 function, and not all Name1, Name2, Name3, etc.
Is it possible to implement this?
Example:

Для основного:
var example1 = cluster.fork();
example1.on('message', function(m) {
});

Для дочернего (бота):
process.send('');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2016-10-11
@vshvydky

I can offer a non-standard solution, communication through the database, there is such a curious thing, rethinkdb is something similar to mongo db, only now it has a super method changes () through which you can subscribe to a certain data filter from the collection and immediately respond to it when it is received .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question