From bcbf441e09fb502cf64924ff2530fa144bdf52c5 Mon Sep 17 00:00:00 2001 From: Andreas Brachold Date: Mon, 13 Aug 2007 18:41:27 +0000 Subject: * Move files to trunk --- lib/XXV/OUTPUT/HTML/PUSH.pm | 95 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 lib/XXV/OUTPUT/HTML/PUSH.pm (limited to 'lib/XXV/OUTPUT/HTML/PUSH.pm') diff --git a/lib/XXV/OUTPUT/HTML/PUSH.pm b/lib/XXV/OUTPUT/HTML/PUSH.pm new file mode 100644 index 0000000..7c7d7df --- /dev/null +++ b/lib/XXV/OUTPUT/HTML/PUSH.pm @@ -0,0 +1,95 @@ +package XXV::OUTPUT::HTML::PUSH; + +use strict; + +use Tools; + +$| = 1; + +=head1 NAME + +XXV::OUTPUT::HTML::PUSH - A Push for http system + +=head1 SYNOPSIS + + use XXV::OUTPUT::HTML::PUSH; + + my $pusher = XXV::OUTPUT::HTML::PUSH->new( + -cgi => $obj->{cgi}, # The CGI Object from Lincoln Stein + -handle => $obj->{handle}, # The handle to printout the http Stuff + ); + + $pusher->start(); # Start the Push Process + + while($c > 10) { + $pusher->print($c++); # Print out the message + } + + $pusher->stop(); # Stop the Push + + +=cut + +# ------------------ +sub new { +# ------------------ + my($class, %attr) = @_; + my $self = {}; + bless($self, $class); + + $self->{handle} = $attr{'-handle'} + || return error('No handle defined!'); + + $self->{cgi} = $attr{'-cgi'} + || return error('No CGI Object defined!'); + + return $self; +} + +# ------------------ +sub start { +# ------------------ + my $obj = shift || return error ('No Object!' ); + my $out = shift || 0; + $obj->{handle}->print($obj->{cgi}->multipart_init(-boundary=>'----here we go!')); + $obj->print($out) if($out); +} + +# ------------------ +sub print { +# ------------------ + my $obj = shift || return error ('No Object!' ); + my $msg = shift || return; + my $type = shift || 'text/html'; + + $obj->{handle}->print($obj->{cgi}->multipart_start(-type=>$type)); + $obj->{handle}->print($msg."\n"); + $obj->{handle}->print($obj->{cgi}->multipart_end); +} + +# ------------------ +sub follow_print { +# ------------------ + my $obj = shift || return error ('No Object!' ); + my $msg = shift || return; + my $type = shift || 'text/html'; + + unless($obj->{header}) { + $obj->{handle}->print($obj->{cgi}->multipart_start(-type=>$type)); + $obj->{header} = 1; + } + $obj->{handle}->print($msg."\n"); +} + +# ------------------ +sub stop { +# ------------------ + my $obj = shift || return error ('No Object!' ); + $obj->{handle}->print($obj->{cgi}->multipart_end); + $obj->{handle}->print($obj->{cgi}->header( + -type => 'text/html', + -status => "200 OK", + )); +} + +1; -- cgit v1.2.3