lib/processMessenger/index.js
function bindMessageListener(worker) {
		worker.on('message', function (msg) {
			// Ignore the message if it doesn't belong to the namespace
			if (msg.namespace !== that.namespace) {
				return;
			}

			// If the address is '*', it's a broadcast message
			// Send the message to all the workers
			if (msg.to === '*') {
				that.broadcast(msg.name, msg.data, msg.from);
			}

			// If the address is 'master', emit an event with the message details
			// If the message is a broadcast message, it should also emit an event
			if (msg.to === 'master' || msg.to === '*') {
				that.emit(msg.name, msg.data, msg.from);
				return;
			}

			// If the master is not the recipient, forward the message
			that.send(msg.to, msg.name, msg.data, msg.from);
		});
	}
function bindMessageListener(worker) {
		worker.on('message', function (msg) {
			// Ignore the message if it doesn't belong to the namespace
			if (msg.namespace !== that.namespace) {
				return;
			}

			// If the address is '*', it's a broadcast message
			// Send the message to all the workers
			if (msg.to === '*') {
				that.broadcast(msg.name, msg.data, msg.from);
			}

			// If the address is 'master', emit an event with the message details
			// If the message is a broadcast message, it should also emit an event
			if (msg.to === 'master' || msg.to === '*') {
				that.emit(msg.name, msg.data, msg.from);
				return;
			}

			// If the master is not the recipient, forward the message
			that.send(msg.to, msg.name, msg.data, msg.from);
		});
	}
function bindMessageListener ( worker ) { worker . on ( 'message' , function ( msg ) { // Ignore the message if it doesn't belong to the namespace if ( msg . namespace !== that . namespace ) { return ; } // If the address is '*', it's a broadcast message // Send the message to all the workers if ( msg . to === '*' ) { that . broadcast ( msg . name , msg . data , msg . from ) ; } // If the address is 'master', emit an event with the message details // If the message is a broadcast message, it should also emit an event if ( msg . to === 'master' || msg . to === '*' ) { that . emit ( msg . name , msg . data , msg . from ) ; return ; } // If the master is not the recipient, forward the message that . send ( msg . to , msg . name , msg . data , msg . from ) ; } ) ; }
Add a listener to process the message received from the specified worker
Add a listener to process the message received from the specified worker