lib/SlaveChildProcess.js
/**
 * Sends the response message to the master process.
 * @param {Object} req The original request from the master.
 * @param {Object} res The results from the request execution.
 * @return {undefined}
 */
Sends the response message to the master process.
@param {Object} req The original request from the master.
@param {Object} res The results from the request execution.
@return {undefined}
Sends the response message to the master process . @param { Object } req The original request from the master . @param { Object } res The results from the request execution . @return { undefined }
function sendMessageToMaster(req, res) {
  const response = {
    title: 'SlaveIOResponse',
    sent: Date.now(),
    request: req,
    error: null,
    data: undefined,
    [req.secretId]: req.secretNumber,
  };
  delete req.secretId;
  delete req.secretNumber;
  if (res instanceof Error) {
    response.error = { message: res.message, stack: res.stack, name: res.name };
  } else {
    response.data = res;
  }
  slaveInstance.emit('sending message', response);
  if (process.send instanceof Function) {
    process.send(response);
  } else {
    throw new Error('Fatal: Disconnected from master process.');
  }
}
function sendMessageToMaster ( req , res ) { const response = { title : 'SlaveIOResponse' , sent : Date . now ( ) , request : req , error : null , data : undefined , [ req . secretId ] : req . secretNumber , } ; delete req . secretId ; delete req . secretNumber ; if ( res instanceof Error ) { response . error = { message : res . message , stack : res . stack , name : res . name } ; } else { response . data = res ; } slaveInstance . emit ( 'sending message' , response ) ; if ( process . send instanceof Function ) { process . send ( response ) ; } else { throw new Error ( 'Fatal: Disconnected from master process.' ) ; } }
Sends the response message to the master process.
Sends the response message to the master process .
// The actual message to send to the master process... // Remove these as the above will be exposed. // Add each result, either as an error, or data. /**
   * Emitted when a slave process is sending a message to it's master
   * @event sending message
   * @argument {Obkect} response The response message the slave is sending.
   */