Msg#: 4060314 posted 12:42 am on Jan 14, 2010 (gmt 0)
Let's say this is for a PHP-driven game, run client-side via browser. If I don't want the script to wait for input from players, again, let's say there are entities in the game which will act on their own and I'd like them to do that even when no one is actually playing. How do I pull that off without hogging a server's resources?
Msg#: 4060314 posted 1:15 am on Jan 14, 2010 (gmt 0)
I'm not sure, but one thought I'm having is to look at pre-compiling your script and see if that makes it possible for you... One of the problems with constant running is browsers and servers timing out the script execution. (If you're on your own box you have more flexibility here, but otherwise you probably won't be able to have the script run constantly, unless maybe you can somehow do it by pre-compiling.) There's one I run that takes literally a couple of days and I have to set a meta refresh on it for every 40 seconds (using firefox) and then when I hit the max redirects I have to manually reload the page and start it over.
Not sure on other options, maybe someone else has some better ones...
Msg#: 4060314 posted 1:28 am on Jan 14, 2010 (gmt 0)
Yeah, I was thinking AJAX myself. I know a PHP script can be opened and left running, but it seems to me it'd be a lot easier to just use a backend AJAX app on my client and couple that with whomever else is accessing the script... so if the power goes out or something the script will still be running. Maybe.
Msg#: 4060314 posted 6:10 am on Jan 14, 2010 (gmt 0)
I have, and I've also considered how stubborn I am. I know PHP/MySQL and DHTML... and every time I attempt to do something with C++ or similar languages I hit a brick wall of libraries and a lack of documentation.