CGI::JSONRPC::Obj - Base class for easy handler creation
package MyHandler; use CGI::JSONRPC::Obj; sub jsonrpc_javascript { my $js; # construct javascript object return } sub do_something { # handler that jsonrpc will call... }
CGI::JSONRPC::Obj is a base class you can use to ease the creation of object handlers. Although it's fairly trivial to roll your own we recommend that all handlers use this class for forward compatablity reasons.
This object can all be viewed as documenting and defining the behaviour required of all objects served via CGI::JSONRPC.
When a CGI::JSONRPC call is dispatched the following happens:
The dispatcher calls the jsonrcp_new method for you object passing the id value recieved from javascript.
The dispatcher will then call your method passing in the arguments recieved in the call.
The dispatcher will return the output of the json_javascript method.
Constructs the jsonrpc_object and inititializes it from the passed id if appropriate. By default there is no serialization of objects so it is the sole responsibility of all base classes to implement it. (see CGI::JSONRPC::Obj::Session for an example)
Should return the javascript that is the javascript expression of this object. By default this returns the empty string.
Convenience method that returns a javascript safe expression of this objects class. Never called by the dispatcher but can be used to generate the name to be passed in the class argument in subsequent CGI::JSONRPC calls.
Tyler "Crackerjack" MacDonald <japh@crackerjack.net> and David Labatte <buggyd@justanotherperlhacker.com>.
A lot of the JavaScript code was borrowed from Ingy döt Net's Jemplate package.
Copyright 2006 Tyler "Crackerjack" MacDonald <japh@crackerjack.net>
This is free software; You may distribute it under the same terms as perl itself.
The "examples" directory (examples/httpd.conf and examples/hello.html), JSON::Syck, http://www.json-rpc.org/.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'döt'. Assuming UTF-8
To install CGI::JSONRPC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::JSONRPC
CPAN shell
perl -MCPAN -e shell install CGI::JSONRPC
For more information on module installation, please visit the detailed CPAN module installation guide.