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: @package_version@
  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.     
  29.     var $initMethods = true;
  30.  
  31.     // init method for the test class, includes needed files an registers it for ajax
  32.     
  33.     function initTest({
  34.         include 'support/test.class.php';
  35.         $this->registerClass(new test());
  36.     }
  37.  
  38.     // init method for the livesearch class, includes needed files an registers it for ajax
  39.     
  40.     function initLivesearch({
  41.         include 'support/livesearch.class.php';
  42.         $this->registerClass(new livesearch());
  43.     }
  44.  
  45.     // 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
  46.     
  47.     function initTestHaa({
  48.         include 'support/testHaa.class.php';
  49.         $this->registerClass(new testHaa(),'testHaa',array('updateClassName'));
  50.     }
  51.     
  52.     
  53. }
  54.  
  55. $server = new TestServer();
  56.  
  57. // handle requests as needed
  58. $server->handleRequest();
  59. ?>

Documentation generated on Sat, 05 May 2007 18:00:24 -0400 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.