summaryrefslogtreecommitdiff
path: root/lib/XXV/OUTPUT/HTML/PUSH.pm
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-08-13 18:41:27 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-08-13 18:41:27 +0000
commitbcbf441e09fb502cf64924ff2530fa144bdf52c5 (patch)
treef377707a2dac078db8cd0c7d7abfe69ac1006d71 /lib/XXV/OUTPUT/HTML/PUSH.pm
downloadxxv-bcbf441e09fb502cf64924ff2530fa144bdf52c5.tar.gz
xxv-bcbf441e09fb502cf64924ff2530fa144bdf52c5.tar.bz2
* Move files to trunk
Diffstat (limited to 'lib/XXV/OUTPUT/HTML/PUSH.pm')
-rw-r--r--lib/XXV/OUTPUT/HTML/PUSH.pm95
1 files changed, 95 insertions, 0 deletions
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;