# HG changeset patch # User Dan Fuhry # Date 1353343114 18000 # Node ID d9814c4c294853ce3d64f4afa7342dce3914ba9d # Parent 24f5610ea589c1b9512d24414ad2904bbefb79fa Add Output class for Comet (HTTP incremental streams) -- experimental and not working with every browser/apache configuration. diff -r 24f5610ea589 -r d9814c4c2948 includes/output.php --- a/includes/output.php Mon Nov 19 11:37:36 2012 -0500 +++ b/includes/output.php Mon Nov 19 11:38:34 2012 -0500 @@ -273,6 +273,41 @@ } /** + * Output engine that sends data using Comet. This allows incremental pushing of data. + * Note that this tends to not work with every server. + */ + +class Output_Comet extends Output_Naked +{ + /** + * Be warned: this header function will flush ALL output buffers! + */ + + public function header() + { + while ( ob_get_level() ) + ob_end_flush(); + } + + /** + * Write data and immediately send it to the client. + * @param string Data to write + */ + + public function write($data) + { + echo $data; + flush(); + if ( $data === 'STOP' || !stristr(@$_SERVER['HTTP_USER_AGENT'], 'gecko') || stristr(@$_SERVER['HTTP_USER_AGENT'], 'like gecko') ) + { + global $db; + $db->close(); + exit; + } + } +} + +/** * Safe template outputter */