php - Frequent Ajax calls (2-3 times per second) -


i creating game, user moving main object (left/right/up/down). every time moves it, make request server, php place position of player onto map.

the game fast, user should move 2-3 times per second, after 196-200 request error, , not able connect server 3-5 minutes, not good.

how can solve issue considering have full access control panel , can not change request frequency?

sometimes http server or firewall blocks these request prevent ddos attacks.

to solve problem, can use websocket (https://en.wikipedia.org/wiki/websocket) instead of ajax calls.

for each ajax call, browser made these steps:

request 1:

- open connection - request - response - close connection 

request 2:

- open connection - request - response - close connection 

but if use websockets can just:

- open connection - request - request - request - request - request - request - response - request - request - request - (...) 

and close step executed when change page, close browser or force close websocket connection via api.

that solution created these scenarios, , there html game engines using solution multiplayer games (such http://www.isogenicengine.com/)

for php can use ratchet (http://socketo.me/) or php-websockets (https://github.com/ghedipunk/php-websockets) implementation.

i hope helps


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -