.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .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" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "JavaScript::RPC::Server::CGI 3pm" .TH JavaScript::RPC::Server::CGI 3pm "2016-12-17" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" JavaScript::RPC::Server::CGI \- Remote procedure calls from JavaScript .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package MyJSRPC; \& \& use Carp; \& use base qw( JavaScript::RPC::Server::CGI ); \& \& 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 ]; \& } \& \& 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 ]; \& } \& \& package main; \& \& use strict; \& \& 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" .SS "\fInew()\fP" .IX Subsection "new()" Creates a new instance of the module. No further options are available at this time. .SS "\fIquery()\fP" .IX Subsection "query()" Gets / sets the query object. This has the side effect of extracting the \&\fIenv()\fR data. .SS "\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(); \& \& return $q; \& } .Ve .SS "\fIenv()\fP" .IX Subsection "env()" Gets / sets a hash of information related to the currently query. The resulting structure contains four items: .IP "\(bu" 4 method \- the method called .IP "\(bu" 4 params \- an array of parameters for the method .IP "\(bu" 4 uid \- the unique id for this query .IP "\(bu" 4 context \- the context id .SS "\fIerror_message()\fP" .IX Subsection "error_message()" Get / sets the error message sent to the client if an error occurred. .SS "\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. .SS "\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. .SS "\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 "\(bu" 4 http://www.ashleyit.com/rs .SH "AUTHOR" .IX Header "AUTHOR" .IP "\(bu" 4 Brian Cassidy .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.