ipc.js
* @module greppy/app/cluster/worker/ipc
* @author Hermann Mayer <hermann.mayer92@gmail.com>
process.on('message', function(msg) {
var callback = self.callbacks[msg.method];
callback.apply(self, [msg.error, msg.result, msg]);
* Add an listener for an specific IPC broadcast request.
* @param {String} name - Name of the broadcast message
* @param {Function} callback - Function to call on an given IPC broadcast request
IPC.prototype.addBroadcastListener = function(type, callback)
this.callbacks[type] = callback;
* Do an IPC request on the cluster master.
* @param {String} method - Name of the method
* @param {Mixed} args - Argument(s) to pass to the method, Objects are prefered
* @param {Function} [callback] - Function to call on an given IPC response
IPC.prototype.request = function(method, args, callback)
this.callbacks[method] = callback;
* Low-level call of Node.js process communication API.
* It simply wraps the "process.send()" method.
* @param {Object} message - Message object to send