The original muds didn’t need this because telnet, but with the spaceship game in mind, I need some way to sync game-data back and forth between server and client.
Without any hard work, the poll looks like this:
- C: “Server, hit me. I got you some inputs: I1”
- S: “Hit! H1”
- C: “Server, hit me, inputs I2”
- S: “Hit! H2”
So if you have a 200msec lag time, you get a hit every 400msec. That’s assuming upload and download lag are similar.
If you go a little crazier you can work with intermediate frames:
- Setup: Real Time clock R = 0, corresponds to CT=1000 and ST=2000. Neither server nor client can know R. Upload lag 200ms, download lag 50ms
- R=0, Client sends “hit me, CT=1000”
- R=200, Server receives hit request at ST=2200. maybe it takes 15 msec to put together the response.
- R=215, server sends H1 CT1=1000 ST1=2200 ST2=2215
- R=265, client receivesH1 CT1=1000 ST1=2200 ST2=2215 at CT2=1265
- Client now knows that round trip time is about 265 msec. Maybe it takes 20msec to put everything where it goes
- R=285, client sends “hit me H2 CT=1285 Intermediate frame: 133ms”
- R=485, server receives the above request.
- R=500, server sends H2
- R=550, client receives H2
- R=633, server sends H2.1 as requested
- R=683, client receives H2.1
I haven’t coded it yet, but the client is in charge of throttling, and there’s going to be some interesting “what did I try before” “what shall I try now” logic.
There’s also a limit. If the client requested too many intermediate frames, the actual network transport might start bundling the frames together and/or delivering them out of order.
Note that upload and download lag are different – so it might be completely plausible to have 2 or 3 intermediate frames before the client can actually send back its next update.
A more advanced algorithm would have the server asking the client for intermediate frames, but I don’t live in a reality where that needs to be solved.
There’s also some work in the above protocol to figure out server to client time offset. Its not an easy question to handle. And there are also drifting lag speeds – as I write this attached to a 3G Karma Go device. which keeps going from 2 to 3 circles and back.
Dialing it back
I don’t need to solve it all now. For starters – all I need is a simple loop. When I get to space ships floating around and changing direction based on user input, then I’ll need the intermediate frame update stuff. Just need to know it is solvable.