How to make a game in real time on laravel?

You need to make the game. The meaning is, under certain conditions, the game launches and goes such as exactly 49 seconds. During this time, users doing different actions and each action should be shown to all users. Ie, if one pressed the button then on the page the rest will appear this inscription. Also on the page needs to go visual timer and when you refresh the page everything should be preserved and continued. And when the game ends you must be running some sort of action. So here's the question, suggest how to implement it. Yet invented, larabel HTTP gets from the user and transmits using Redis for Socket.io, and he's already in the browser. But not figured out how to be with a timer. Tell me
June 14th 19 at 20:40
3 answers
June 14th 19 at 20:42
The timer on the server.
With node? - keshaun_Hetting commented on June 14th 19 at 20:45
you're on larval going to do, which works in php, what's the node? - Durward_Osinski commented on June 14th 19 at 20:48
on JS - Jamaal_Bode commented on June 14th 19 at 20:51
June 14th 19 at 20:44
Take Node and web sockets.
June 14th 19 at 20:46
Master-timer is started on the server. Rather, there is counted the time with just and which is to receive events from users.

For the user is as important the precision of time. Therefore, the client need to end the game. For time synchronization of the client with the server via a slow, changing on the fly the delay network has a time synchronisation Protocol NTP (as NTP runs).

You will need a similar algorithm, but not setting the system time on the client and the receiving client date-time, respectively. the end of the counter on the server.

For example, on the server the game ends at 12:34:56. Now at server time 01:23:45 (let's assume it is not 49 comes with, but much longer). And the client is now 04:21:00. The objective is to get time on the client when the server will come 12:34:56.

The first ping went away with a client at 04:21:00, and returned from server time 01:23:47 3 seconds at 04:21:03. We believe that the server's response came in the middle of our piece in 3 seconds. From this we get the client time when the end of the game.

These pings can be repeated again and again, specifying the end time. And the countdown timer run setTimeout'ohms in a short period of less than one second, for example. 200ms. And he shows how much left until the adjusted time of the end of the game.

Find more questions by tags LaravelSocket.ioPHP