I am studying how to build a simple Node.js-based socket communication server using Socket.io within Unity.
Since I have very little experience with web development and this is my first time using socket.io, I am currently experimenting with various things. However, I have gained some insights, so I will try to organize them whenever I have a spare moment.
socket.io is largely divided into server-side and client-side development.
To deliver data to clients from the server side, the command "emit" is used.
It is used in the following format.
socket.emit("functionName", "message");
However, if the client sends information and then sends that information to all clients? Since the client who sent the information to the server already knows that information, unnecessary work or duplicate work may occur.
Therefore, in socket.io, there is a command that sends data to everyone except the sender. This is broadcast.
It is used in the following way.
socket.broadcast.emit("functionName", "message");
By using this, data transmission is possible to all other connected clients, excluding the client that is the source of the information.
It seems like it would be useful if used well.
The more I use it, the more I think socket.io is really well-made.