8.39. CGI::Push
Provides an interface to do server push
operations, letting you rewrite pages with content that changes
regularly. A server push operation automatically sends updates to a
page on a push-capable browser. CGI::Push exports the function
do_push to implement page redraws. This method can
be used on a CGI::Push object or on its own:
$q = new CGI::Push;
$q->do_push(-next_page => \&sub);
or:
do_push (-next_page => \&sub);
do_push requires one argument: a reference to a
subroutine that will draw the next page. You may optionally specify a
subroutine that draws the last page and the interval between page
updates. Additional parameters to do_push are
those that can be used with a CGI::headers object.
do_push (params)
Implements a server push operation, which updates a page at specific
intervals. Parameters are:
- -delay => n
-
Specifies the number of seconds, n, to
wait before the next call to the page-drawing subroutine.
- -last_page => \&sublast
-
Runs the subroutine sublast to draw the
last page update of a server push operation. The
-last_page routine is invoked when the
-next_page routine returns false. A reference to a
subroutine glob should be provided for this parameter, but the name
of the subroutine is also acceptable.
- -next_page => \&sub
-
sub is the name of the subroutine
responsible for redrawing the page and counting the number of
iterations (if you want repeated updating). The
do_push routine ends when
sub returns false (or when the
-last_page subroutine is invoked). A reference to
a subroutine glob should be provided for this parameter, but the name
of the subroutine is also acceptable.
- -type = string
-
Specifies the content type of the pushed data. The default value is
textl.