I am working on a project to find out node.js, and have been looking for some recommendations on how to handle user data synchronization in real time.
Let's say you have a two-dimensional rectangular map (approximately 600x400), with the number of players occupying x, y positions on this map. Each user can navigate the arrow keys and interact with others mainly. Given that this will be playable via HTTP, what would be the best design pattern in terms of processing and synchronizing user data to give the smoothest and fastest way?
I can think of several options, but would like to get some more ideas / clarifications:
The client sends positional data to the server, the server distributes all positions to all clients, the screen is displayed with the result. Reiteration. The disadvantage would be that the client side lags behind the time spent on data transfer, but at the top is that they are synchronized with all users.
The client displays where he thinks he is constantly sending the positional data to the server, the server distributes all the positions to all the clients, and then displays the rendering of the client data with the server data on the screen. Growth potential is a faster response, the disadvantage is a slight loss of synchronization.
A mixture of two, but instead of using (x, y) coordinates, we use the vector [previous x / y and time, current x / y and time suggested by x / y at time interval], which can then be used to draw the trajectories of shells, which constantly changing. It seems like it would be difficult to implement.
Any pointers?
source
share