temporizador del servidor del cliente, que se muestra en el lado del cliente (js) y no se puede engañar

i have client side game in js that have stage which count down the time in minutes now i save few steps of the game in server side also .
but i know that sometimes that browser is slow and less responsive so the 4 minutes i count in the server side are not 4 minutes in the client .
how can i make this consist?
so its can't be cheated ?

preguntado el 23 de abril de 13 a las 13:04

1 Respuestas

Build a keep-alive system. Every 30 seconds or so, send in a time-dependent variable (timestamp or encrypted variation thereof), and get it received by the server. Server calculates the difference, sends back the difference to the client. This way, you know every 30s what the difference is, which allows you to adjust accordingly.

This does not cover for lag - instead, it allows you to adapt. This also does not take into account the time it takes for the request to fire, so take the difference with a pinch of salt.

Respondido 23 Abr '13, 13:04

one thing i need to consider is as much less requests doing to the server - user63898

This is why I suggested requesting every 30 seconds. On average, that's 8 requests per 4min timer, and all you need to do in terms of ops on the server is this: <?php echo time()-$user_timer; ?> (after validation of the user's timestamp, obviously). - Sébastien Renauld

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.