Open
Description
Is your feature request related to a problem? Please describe.
It took me way too long to figure out that to communicate between shards (i.e. to have one shard communicate something to all other shards) is done by making use of manager.broadcast
and process.on
. This info is not available in the chapter about shard communication.
Describe the solution you'd like
Information or a code sample that roughly goes like this:
manager.spawn()
.then(shards => {
shards.forEach(shard => {
shard.on('message', message => {
manager.broadcast(message);
});
});
})
.catch(console.error);
process.on('message', (message: string) => {
const data = JSON.parse(message);
console.log(data.message);
});
process.send(JSON.stringify({ message: 'Hello World!'}));
And if I'm doing somehting wrong here, well I guess it's because the guide didn't teach me.
Describe alternatives you've considered
No response
Additional notes
No response