File: README

package info (click to toggle)
libjavascript-rpc-perl 0.10-2
  • links: PTS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 136 kB
  • sloc: javascript: 256; perl: 151; makefile: 2
file content (131 lines) | stat: -rw-r--r-- 4,348 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
NAME
    JavaScript::RPC::Server::CGI - Remote procedure calls from JavaScript

SYNOPSIS
            package MyJSRPC;
        
            use Carp;
            use base qw( JavaScript::RPC::Server::CGI );
        
            sub add {
                    my $self = shift;
                    my @args = @_;
                    unless(
                            @args == 2 and
                            $args[ 0 ] =~ /^\d+$/ and
                            $args[ 1 ] =~ /^\d+$/
                    ) {
                            croak( 'inputs must be digits only' ); 
                    }
                    return $args[ 0 ] + $args[ 1 ];
            }
        
            sub subtract {
                    my $self = shift;
                    my @args = @_;
                    unless(
                            @args == 2 and
                            $args[ 0 ] =~ /^\d+$/ and
                            $args[ 1 ] =~ /^\d+$/
                    ) {
                            croak( 'inputs must be digits only' );
                    }
                    return $args[ 0 ] - $args[ 1 ];
            }
        
            package main;
        
            use strict;
        
            my $server = MyJSRPC->new;
            $server->process;

DESCRIPTION
    JavaScript::RPC::Server::CGI is a CGI-based server library for use with
    Brent Ashley's JavaScript Remote Scripting (JSRS) client library. It
    works asynchronously and uses DHTML to deal with the payload.

    In order to add your custom meothds, this module should be subclassed.

    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.

INSTALLATION
    To install this module via Module::Build:

            perl Build.PL
            ./Build         # or `perl Build`
            ./Build test    # or `perl Build test`
            ./Build install # or `perl Build install`

    To install this module via ExtUtils::MakeMaker:

            perl Makefile.PL
            make
            make test
            make install

METHODS
  new()
    Creates a new instance of the module. No further options are available
    at this time.

  query()
    Gets / sets the query object. This has the side effect of extracting the
    env() data.

  get_new_query()
    This method generates a new query object. It is used internally by the
    query() method. This method should only be used if you want to supply a
    query object other than the standard CGI.pm object. However, it must be
    a CGI.pm compatible object. Here's an example using CGI::Simple.

            sub get_new_query {
                    require CGI::Simple;
                    my $q = CGI::Simple->new();

                    return $q;
            }

  env()
    Gets / sets a hash of information related to the currently query. The
    resulting structure contains four items:

    * method - the method called
    * params - an array of parameters for the method
    * uid - the unique id for this query
    * context - the context id

  error_message()
    Get / sets the error message sent to the client if an error occurred.

  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 CGI.pm compatible object as an input.

    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.

  error()
    Returns a valid error payload to the client and false to the caller. It
    will automatically call error_message() for you.

  result()
    Returns a valid result payload to the client and true to the caller.

SEE ALSO
    * http://www.ashleyit.com/rs

AUTHOR
    * Brian Cassidy <brian@alternation.net>

COPYRIGHT AND LICENSE
    Copyright 2005 by Brian Cassidy

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.