After multiple clients establish connections with the server, the socket.io() server has a sockets attribute, and the attribute value is all the socket objects that have established connections with the client. You can use the send method or emit method of the object to All clients broadcast messages.
io.sockets.send("user communicated);
io.socket.emit("login",names);
Case
server.js code:
Run result:
When logging in in Google Chrome, you can see exactly the same results in Firefox.
This is a wonderful phenomenon and an effect that surprises me greatly.
Such a wonderful node.