AJAX
[ class tree: AJAX ] [ index: AJAX ] [ all elements ]

Source for file slow_server.php

Documentation is available at slow_server.php

  1. <?php
  2. /**
  3.  * A server that adds artificial latency to requests
  4.  *
  5.  * @category   HTML
  6.  * @package    AJAX
  7.  * @author     Joshua Eichorn <josh@bluga.net>
  8.  * @copyright  2005 Joshua Eichorn
  9.  * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
  10.  * @version    Release: 0.5.4
  11.  * @link       http://pear.php.net/package/HTML_AJAX
  12.  */
  13.  
  14.  // include the server class
  15. include 'HTML/AJAX/Server.php';
  16.  
  17. // don't add delays to client library requests
  18. if (!isset($_GET['client']&& !isset($_GET['stub'])) {
  19.     if (!isset($_SESSION['sleep']|| $_SESSION['sleep'== 0{
  20.         $_SESSION['sleep'= 5;
  21.     }
  22.     sleep($_SESSION['sleep']--);
  23. }
  24.  
  25. // extend HTML_AJAX_Server creating our own custom one with init{ClassName} methods for each class it supports calls on
  26. class TestServer extends HTML_AJAX_Server {
  27.     // this flag must be set to on init methods
  28.     var $initMethods = true;
  29.  
  30.     // init method for the test class, includes needed files an registers it for ajax
  31.     function initTest({
  32.         include 'support/test.class.php';
  33.         $this->registerClass(new test());
  34.     }
  35.  
  36.     // init method for the livesearch class, includes needed files an registers it for ajax
  37.     function initLivesearch({
  38.         include 'support/livesearch.class.php';
  39.         $this->registerClass(new livesearch());
  40.     }
  41.  
  42.     // init method for the testHaa class, includes needed files an registers it for ajax, directly passes in methods to register to specify case in php4
  43.     function initTestHaa({
  44.         include 'support/testHaa.class.php';
  45.         $this->registerClass(new testHaa(),'testHaa',array('updateClassName'));
  46.     }
  47.     
  48.     
  49. }
  50.  
  51. $server = new TestServer();
  52.  
  53. // handle requests as needed
  54. $server->handleRequest();
  55. ?>

Documentation generated on Fri, 04 Apr 2008 18:30:26 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.