What is the best way for keeping all clients synchronized with a server and with each other?
Currently, we have two approaches in mind:
- When a client sends something to the server, the server immediately sends out messages to all clients, which react immediately.
- Introducing some time delay, whereby the server sends out messages to all clients, with the directive, "act upon this at time
t
.
The second approach seems like it would more likely keep the clients all in better synchronization (since it caters for some degree of lag); but I wonder whether responsiveness would be lost to too high a degree (i.e. the user clicks 'jump' and there is a noticeable gap between pressing the button and actually jumping).
There is also the possibility of having clients calculate their own position (and not wait for servers to say "you have jumped"); but because of the inevitable lag, clients would get very out-of-sync.
Then there's the whole TCP vs. UDP question; because we want it fast, but I'd also hate for the server to say you're in a completely different location than you thought you were.
With all of these competing demands, it all gets very uncertain how we should approach this issue. Which of these approaches (or any other) would be best for keeping clients and server all in sync? Which ones are actually used in the industry?
No comments:
Post a Comment