jestro
jestro

Reputation: 2593

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

I am currently working with Java server side and as3 client side. I'm wondering if there is a silver bullet out there for synchronizing the clock between them. Between variable latency and variable clock speeds it seems like each packet would need a timestamp.

Thanks!

Upvotes: 6

Views: 2897

Answers (2)

Cin316
Cin316

Reputation: 651

This is just off the top of my head, without any code.

  1. Put code in the server and client to send and receive a ping.
  2. Send a ping from the client to the server every time the client connects.
  3. Record the current time as te send time.
  4. When the client receives the ping, record the current time at the receive time.
  5. Get the time delay by subtracting the receive time by the send time and divide it by 2.
  6. Have the server send the current time to the client.
  7. Subtract the time difference from the time server sent.
  8. Set the client time to the time from step 6.

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

Upvotes: 2

Mihai Raulea
Mihai Raulea

Reputation: 438

No, there is no silver bullet.You will have to improvise.The timestamp is a good idea. Also, try to keep to a minimum the computation done on the server.Don't simulate irrelevant stuff.Just things that you think will break up your game logic.Let the clients compute the rest, and only broadcast the results to your subscribers.

Upvotes: 0

Related Questions