In my chat app i have public chats and messages should be broadcasted to everyone, I'm using WebSocket in NodeJS.
I saw in Socket.io or other frameworks it iterates over the clients one by one and sends the message, This doesn't seem to be an optimal solution. Is there another way (alternative) to do that without using Loops?
I've also seen others use RabbitMQ in their chat apps, Is RabbitMQ what i want? or What exactly is it used for?
const clients = [...];
clients.forEach(client => {
client.send("Message!");
});
question from:
https://stackoverflow.com/questions/65883132/broadcast-a-message-to-all-clients-without-using-loops 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…