This is a modification of my last posting, seeing I have narrowed down what I want to do for my application. Here's the rundown.
This application, for all intents and purposes, is to create a psuedo event-based PHP scripting system that allows text to be printed to the screen without refreshing the page. Yes this is similar to Till Gerken and Tobias Ratschiller's PHP Chat except one major difference. It uses semaphores instead of DB flags.
When the application is loaded, a frameset will be created. In the main frame is the window we will want to print our output to. The second frame will be an input box for commands along with the code to update the semaphore and create the DB entries.
When the script is executed, the print frame will enter into a continual loop which checks for a certain semaphore value. Now if the value isn't found, the semaphore halts the current process (effectively pausing the entire script). While this script is paused, the connection to the user is still open (and they said PHP was stateless! 😛) and the command input box is still functional. When the user enters a command, the command frame refreshes with its own HTTP POST data and writes the users's command to a SESSION variable. The script then updates the semaphore with a new value. Now back to our main window, the loop thats been paused all this time jumps back to life when the semaphore is updated. The contents of the loop then check for the SESSION variable and grab the command we just stuck into it. It connects to the DB and does a lookup for the action and/or text it's supposed to associated with this command. Whether the command is found our not we are going to output to the screen so we do some simple error checking and create a message string. The loop then uses a flush() to print the message to the screen and clears the SESSION variable. It also updates the semaphore back to its original value. The loop has now finished and goes back to the beginning where it finds the semaphore is not what we want.. and pauses the loop again. (waiting for the next command)
So this is in effect my prospectus for an event-based message posting system.
Ok so why did I just type all this out? Simple. I want to know three things: First, will this work with little overhead by pausing the process and effectively not writing anymore to ram (we could even refresh the page every 5 or 10min or so just to make sure we don't overload)? Can this idea support roughly 300 - 600 users without causing the server to go into a fatal swap? Lastly, if neither of the two above, can you think of another way to do this without using a different language or refreshing the page 😃.
Thanx guys!
Jace
(the guy who brought you the IE5 force download that took 3 months to figure out 😃)