faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

51 of 74 people (69%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

Can PHP send an update signal (popup screen) to other users when a user makes a request on a game?

Mar 1st, 2009 08:50
Sarah Turner, healthy man, dman, Jonathan Sharp, sheeta laputa, http://www.ttnr.org


Because of the limitations of HTTP it's not possible to "PUSH" or have 
the server initiate a connection to a client. This is because HTTP is a 
connection-less protocol and one of the reasons session management is a 
hot topic. 
But here is a possible solution. If you had two clients, A & B who were 
both playing your game. If client A makes a request, you could have a 
PHP script on your server drop that request into a MySQL database and 
then every client that is playing would have a popup window that would 
auto-refresh every 15 seconds (anything faster is a waste of resources, 
you might even bump it up to 30 seconds). When it would refresh the PHP 
script would query the database for the latest "events" and if one had 
occurred, it would print out some javascript which would launch a popup 
for each user. Now let me warn you that this can become resource 
intensive very fast. If you have say 3 games occurring at the same time 
with 15 players per game, you're looking at 45 queries against your db 
every 15 seconds and if you are on a virutal server or shared hosting 
package...they might not like that.
Another cool feature would be to use a framset where one frame is set 
at 100% and the other 0% (so it's a hidden frame) The hidden frame 
would be the one which auto-refreshes so it would appear "transparent" 
to the players.
http://www.healthdothealth.com
http://www.healthxhealth.com
http://www.mesotheliomainmesothelioma.com
http://www.healthfirewall.com
http://www.flathealth.com
http://www.healthbodyguard.com
http://voyagevacances.blogtact.com/
http://rejseferie.blogtact.com/
http://flyvningertilschweiz.blogtact.com/
http://volssuisse.blogtact.com/
http://volsromeitalie.blogtact.com/
http://viajesvacaciones.blogtact.com/
http://reisenchina.blogtact.com/
http://flugeschweiz.blogtact.com/
http://resasemester.blogtact.com/
http://viaggivacanze.blogtact.com/
http://reisenurlaub.blogtact.com/
http://reizenvakanties.blogtact.com/
http://volisvizzera.blogtact.com/
http://gartenpflege.blogtact.com/
http://geschenkideeen.blogtact.com/
http://vluchtenromeitalie.blogtact.com/