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

2

6

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!

Latter answered 6/4, 2012 at 4:0 Comment(4)
@Thomas That's good for system times -- but this is more of a matter of event synchronization and latency and avoid having the client cheat or render [unbelievable] inaccurate information, etc.Demonstration
do your modeling both server side and client side. limit client input to that of a mouse and keyboard. you can never get 100% accurate with timing and will have to make estimations and do gradual corrective action.Atmospherics
Is seems like you're looking for a client-time-based cheating detection system? What if you compared the server time to the client time on log-in/init, and disallowed any actions that occur outside a certain chronological buffer based on that initial sync?Osmond
What does a packet between these two usually look like, with what you have so far? I think you're dead right with using a timestamp on every packet - that lets you check if an action is possible given the order, what time things happened, et cetera. You can also compare a packet's timestamp to the current time to "fast forward" to the present any information that's delayed a bit.Mcardle
T
2

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!

Tho answered 6/4, 2012 at 4:0 Comment(1)
Yes, i think, this is the right way. Conceptually, you have to store time stamps on each of the client as well as the server. And adjust time on each of them by knowing the time offset.Desultory
F
0

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.

Fadeless answered 7/4, 2012 at 16:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.