pi.comet.Push Classes
Summary
The classes which provide cross browser outputs.
The classes below arranges data preparation during data transmission from server to client. You may visit the
How It Works page to receive more technical information. If you can not find a class for the programming language of your choice and would like to send me one, please contact me at azer at kodfabrik.com.. Your name, email and website will be added to the site.
PHP Class
Download:
pi.comet.php
Usage Example:
<?php
require_once "pi.comet.php";
$stream = new PIComet($_GET["PICometMethod"],$_GET["PICometName"]);
header(' Content-type: ' $cometApi->header);
for( $i=0; $i<10; $i++ ){
$stream->push( "Unixtime: ".time() ) );
ob_flush();
flush();
sleep(1);
};
?>
Python Class
Download:
pi_comet.py
# This example code is written for CherryPy
from pi_comet import *
stream = PIComet(int(PICometMethod),PICometName)
cherrypy.response.headers['Content-type'] = stream.contentType
i = int(index)
def push(i=i):
for j in range(0,10):
yield stream.push( "Unixtime: "+str(time.time()) )
sys.stdout.flush()
time.sleep(1)
return push()