It seems like all the PHP chat scripts are limited in that they have to keep refreshing the page all the time, or else they rely on additional server processes and (which many hosting providers do not allow).
I thought of a method that doesn't require a server process running continuously in the background, nor do clients have to refresh every 2 seconds to check for updates.
Imagine this process, a simple chat between 3 people (A, B and C).
A, B and C are each waiting for someone to talk. So they each send a request to listen.php on the web server, which starts three instances of listen.php running. Each instance of listen.php creates a FIFO and opens it for reading, which blocks execution. And the chatters await their replies.
Meanwhile, Person A decieds to send a message. So A's browser issues a request to talk.php, which writes to the FIFOs created by the instances of listen.php. This wakes up the instances of listen.php, which return the contents of the message to the clients who are listening.
The process repeats with all the clients requesting listen.php again, meaning that they are ready to listen for more messages.
I haven't implemented this yet. It seems too hard. I would appreciate if someone told me whether or not I am insane for thinking this could work.
Also, any ideas on overcoming the "maximum script execution time" barrier?
Thanks
Will
I thought of a method that doesn't require a server process running continuously in the background, nor do clients have to refresh every 2 seconds to check for updates.
Imagine this process, a simple chat between 3 people (A, B and C).
A, B and C are each waiting for someone to talk. So they each send a request to listen.php on the web server, which starts three instances of listen.php running. Each instance of listen.php creates a FIFO and opens it for reading, which blocks execution. And the chatters await their replies.
Meanwhile, Person A decieds to send a message. So A's browser issues a request to talk.php, which writes to the FIFOs created by the instances of listen.php. This wakes up the instances of listen.php, which return the contents of the message to the clients who are listening.
The process repeats with all the clients requesting listen.php again, meaning that they are ready to listen for more messages.
I haven't implemented this yet. It seems too hard. I would appreciate if someone told me whether or not I am insane for thinking this could work.
Also, any ideas on overcoming the "maximum script execution time" barrier?
Thanks
Will