.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "JavaScript::RPC::Server::CGI 3pm" .TH JavaScript::RPC::Server::CGI 3pm "2005-10-06" "perl v5.8.8" "User Contributed Perl Documentation" .SH "NAME" JavaScript::RPC::Server::CGI \- Remote procedure calls from JavaScript .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package MyJSRPC; .Ve .PP .Vb 2 \& use Carp; \& use base qw( JavaScript::RPC::Server::CGI ); .Ve .PP .Vb 12 \& sub add { \& my $self = shift; \& my @args = @_; \& unless( \& @args == 2 and \& $args[ 0 ] =~ /^\ed+$/ and \& $args[ 1 ] =~ /^\ed+$/ \& ) { \& croak( \(aqinputs must be digits only\(aq ); \& } \& return $args[ 0 ] + $args[ 1 ]; \& } .Ve .PP .Vb 12 \& sub subtract { \& my $self = shift; \& my @args = @_; \& unless( \& @args == 2 and \& $args[ 0 ] =~ /^\ed+$/ and \& $args[ 1 ] =~ /^\ed+$/ \& ) { \& croak( \(aqinputs must be digits only\(aq ); \& } \& return $args[ 0 ] \- $args[ 1 ]; \& } .Ve .PP .Vb 1 \& package main; .Ve .PP .Vb 1 \& use strict; .Ve .PP .Vb 2 \& my $server = MyJSRPC\->new; \& $server\->process; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" JavaScript::RPC::Server::CGI is a CGI-based server library for use with Brent Ashley's JavaScript Remote Scripting (\s-1JSRS\s0) client library. It works asynchronously and uses \s-1DHTML\s0 to deal with the payload. .PP In order to add your custom meothds, this module should be subclassed. .PP The most current version (as of the release of this module) of the client library as well as a demo application have been included in this distribution. .SH "INSTALLATION" .IX Header "INSTALLATION" To install this module via Module::Build: .PP .Vb 4 \& perl Build.PL \& ./Build # or `perl Build` \& ./Build test # or `perl Build test` \& ./Build install # or `perl Build install` .Ve .PP To install this module via ExtUtils::MakeMaker: .PP .Vb 4 \& perl Makefile.PL \& make \& make test \& make install .Ve .SH "METHODS" .IX Header "METHODS" .Sh "\fInew()\fP" .IX Subsection "new()" Creates a new instance of the module. No further options are available at this time. .Sh "\fIquery()\fP" .IX Subsection "query()" Gets / sets the query object. This has the side effect of extracting the \&\fIenv()\fR data. .Sh "\fIget_new_query()\fP" .IX Subsection "get_new_query()" This method generates a new query object. It is used internally by the \&\fIquery()\fR method. This method should only be used if you want to supply a query object other than the standard \s-1CGI\s0.pm object. However, it must be a \s-1CGI\s0.pm compatible object. Here's an example using CGI::Simple. .PP .Vb 3 \& sub get_new_query { \& require CGI::Simple; \& my $q = CGI::Simple\->new(); .Ve .PP .Vb 2 \& return $q; \& } .Ve .Sh "\fIenv()\fP" .IX Subsection "env()" Gets / sets a hash of information related to the currently query. The resulting structure contains four items: .IP "* method \- the method called" 4 .IX Item "method - the method called" .PD 0 .IP "* params \- an array of parameters for the method" 4 .IX Item "params - an array of parameters for the method" .IP "* uid \- the unique id for this query" 4 .IX Item "uid - the unique id for this query" .IP "* context \- the context id" 4 .IX Item "context - the context id" .PD .Sh "\fIerror_message()\fP" .IX Subsection "error_message()" Get / sets the error message sent to the client if an error occurred. .Sh "\fIprocess()\fP" .IX Subsection "process()" Processes the current query and either returns the result from the appropriate method, or an error to the client and returns either true or false, respectively, to the caller. An error will occur if the method name is blank, or the method has not been defined. This function takes an optional \s-1CGI\s0.pm compatible object as an input. .PP Your subclass' method will be evaled and will either return an error to the caller if it died, or return a valid result payload on success. .Sh "\fIerror()\fP" .IX Subsection "error()" Returns a valid error payload to the client and false to the caller. It will automatically call \fIerror_message()\fR for you. .Sh "\fIresult()\fP" .IX Subsection "result()" Returns a valid result payload to the client and true to the caller. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "* http://www.ashleyit.com/rs" 4 .IX Item "http://www.ashleyit.com/rs" .SH "AUTHOR" .IX Header "AUTHOR" .PD 0 .IP "* Brian Cassidy " 4 .IX Item "Brian Cassidy " .PD .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2005 by Brian Cassidy .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.