In main file I have this code:
var forest = require('child_process').fork("forest.js");
forest.emit("go",12,15);
In forest.js:
process.on('message', function(message) {
console.log("Normal message: "+ message);
});
process.on('go',function(x,y){
console.log("EVENT GO THERE:"+ x +"/"+ y);
});
Why when I emits "go" event nothing happen?
I find similar question, and answer which resolve issue: http://stackoverflow.com/a/16509846/2490611. Why I need do this in that way, and can't add listener directly to process ?