php - How to minimalise mysql connections and ajax calls in jQuery game (ping function)? -


i'm writting browser-based game. client in jquery , server in php/mysql.

it's turn-based game, of client-server communication realised call-respond (jquery-php). calls happens time user clicked button or other active element. after call in jquery, php controller creates classes, connects database , returns respond. communication quite me, not cause problems number of connections etc. (it's similar standard trafic during using website).

unfortunatelly, need 'calls' server-side. example list of active games join. client must notify time game list has changed. , maximum delay no more 1 second.

for make sending 'ping' call client (jquery) , server anserws "nothing" time, or "game2 created" etc. 'pings' send every second each of players. , each of them, server create classes , connect mysql results "database connection error".

is there way minimalise mysql connections and/or ajax calls? use standard www server, don't have root account.

start this:

but 'pings' send every second each of players 

instead of calling every second server both players (which 2 calls, number going every player connected), can optimize checking idle time or how time passed of doing nothing; if nothing has been returned 2 continuous calls, should increase call delay 2 seconds , 4 seconds etc. (just play setinterval , make run continuously); allows some breathing app (i had own game using this)

next thing calling policy; instead of calling server in player's command, can store player's command in js array , every x seconds send array off; if no commands, no ajax call. yes, you'll delay think of many users connected possible poor server...

you can use comet technology if want push things further..


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -