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
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
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.