Class: ServerPush

  • Package: saf.CGI
  • Author: John Luxford <lux@simian.ca>
  • Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
  • License: http://www.sitellite.org/index/license Simian Open Software License
  • Version: 1.0, 2002-08-23, $Id: ServerPush.php,v 1.3 2007/10/06 00:06:30 lux Exp $
  • Access: public

ServerPush is a class that implements Netscape's HTTP server push
functionality, allowing incremental data to be presented to the
visitor.

Please note that if you are using this class for progress meter-like
purposes, for the sake of your bandwidth and for your users, do not
send a message for each item being counted, instead wrap something like
this around it:

if ($total > 1000 && $sent % floor ($total / 25) == 0) {
$spush->send ('...', true);
}


Usage Example


<?php

$spush 
= new ServerPush ('replace');

// display the message "Hello, how are you today?" one word at a time
// with a two second delay between words.
$spush->rotate (array (
    
'Hello,',
    
'how',
    
'are',
    
'you',
    
'today?',
), 
2);

?>

Return to Top



Properties


$param = array ()

  • Access: public

Contains a list of the names of all the cookie variables
available to the current script.


$files = array ()

  • Access: public

Contains a list of the names of all the file upload variables
passed to the current script through the POST method.


$error

  • Access: public

Contains an error message that may have been created during
the execution of a transform() call.


$name

  • Access: public

A name for this filter.


$contentType

  • Access: public

The HTTP content type of the pushed document. This can
be either multipart/mixed or multipart/x-mixed-replace, depending
on what you tell the constructor method.


$extraHeaders

  • Access: public

A list of extra HTTP headers to send by sendHeaders().


$key

  • Access: public

The unique key used to separate pushed data blocks. This
value is generated on the fly for you.

Return to Top



Methods


ServerPush ($type = 'mixed')

  • Access: public

Constructor method. $type can be either 'mixed', or 'replace'.


send ($data, $more = true, $contentType = 'text/html')

  • Access: public

Sends a single block to the visitor. If $more is false,
send() calls end() when it is done. $contentType is the content
type for this specific block.


end ()

  • Access: public

Prints a closing key string, ending the transmission.


rotate ($data, $sleep = 1)

  • Access: public

Sends a list of blocks with a delay of $sleep seconds
between them. This is the way web sites used to create basic
animations back in the early days of the web, even before
animated GIFs. $data is an associative array where the keys
are the content type of the data value. If no content type
is specified (ie. the array is not associative), then the
content type will default to text/html.

Return to Top

Copyright © 2008 Sitellite CMS Project

Powered by Sitellite 5.0 Content Management System