Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] php server-side turn-based game

Started by mips Oct 15, 2008 at 11:43 AM 2 replies 1.4k views
Original Post
mips
mips
I want to build a turn based web browser game with java on client side and php on server-side. At the moment the java applet opens a php script from time to time to see if it's the user's turn to do the move or opponent's. Is there any way to notify the user when it's turn occurs?
juanpaco
juanpaco
If the server page tells the Java that it's the user's turn, then just have the Java applet display something to the user.

Or do you mean some way for the server to initiate the communication?
mips
mips
yes I mean how to do it without running that script every few seconds. I guess this is quite inefficient
juanpaco
juanpaco
HTTP isn't the sort of protocol over which you can open and maintain a connection in the same way that you could with managing your own raw tcp/ip or udp-based connection. So, unless you can find some way to get php to run on some server process and communicate over such a connection that you manage yourself, then no.

And yes, it is inefficient to do the polling. :) But it might be tolerable depending on your server/player load.

You could have the client do the polling more intelligently though. If you have some way of knowing on the client side whether or not it is a player's turn, you could have it do its polling for confirmation only at that time.

Though, for turn-based that might not be so doable, since you're waiting on other human players, no? I was getting confused with tick-based, where there is a set amount of time before more "movement points" or whatever become available.

The best I can offer is just have the check to see if it's that players turn be really light-weight and not do the check too terribly often. Perhaps in your play testing you can figure out about how long an "average" turn takes and poll with that frequency.

My advice would be to get the game working and then worry about optimization. I'm building a browser game, and that's the approach I'm taking. Not that that's a good reason to do anything... I'm just sayin'.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.