Synchronize time / events between a player (MMORPG) client and server?

I am currently working on the Java server side and the as3 client side. I am wondering if there is a silver bullet there to synchronize the clock between them. Between variable latency and variable clock speeds, it seems that every packet will need a timestamp.

Thanks!

+6
source share
2 answers

It’s just from the head, without a code.

  • Place the code on the server and client to send and receive ping.
  • Send ping from client to server every time the client connects.
  • Record the current time as the time of sending.
  • When a client receives ping, write down the current time at the time of reception.
  • Get the time delay by subtracting the reception time from the sending time and dividing by 2.
  • The server sends the current time to the client.
  • Subtract the time difference from the sent time server.
  • Set the client time to the time from step 6.

I'm not sure this will work 100% accurate, but I hope this helps!

+2
source

No, no silver bullet. You will need to improvise. Timestamp is a good idea. Also, try to minimize the calculations performed on the server. Do not imitate unnecessary material. Just what you think will ruin your game logic. Let customers figure out the rest and pass on the results to your subscribers only.

0
source

Source: https://habr.com/ru/post/912559/


All Articles