Sunday 15 April 2012

PHP/AJAX: Is it sleep() that blocks all requests to the same script? -


I found a PHP script that is called, does some stuff, then sleeps for 3 seconds, then its Result of Result

And then I have this page which calls the script above (with an Ajax request) for each other 1/10 when I get a response, then I am a I write a number inside the div element

The problem is, the onreadystatechange handler is removed every 3 seconds, and 30 numbers all write together. What other options do I need, like Sleep () ?

Here is the code snippet of the page that has been requested:

  ignore_user_abort (true); $ Time = microtime (true) * 10000; Chengemastatus (1, $ time); // It writes a database (3); If ($ Time & gt; = getmytime ()) {// getmytime () reads data written by first changemystatus () setstatus (0); // still writing that db resonance ("1"); } And resonance ("0"); Actually I want to change the "Status" field in DB to 0 if the user is no longer sending the request (because it has gone, or its connection is down or He has disabled JS or whatever) so that other players know that he is now "offline".   

New answer: If you define some cutoff point then

Say: 5 minutes.

  if ($ Last_active & lt; (time () - 5 * 60)) {// user is inactive}    

No comments:

Post a Comment