Changeset 532

Show
Ignore:
Timestamp:
10/19/07 15:45:55 (6 years ago)
Author:
typester
Message:

lang/perl/POE-Component-Server-JSONRPC: Added documentation

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/POE-Component-Server-JSONRPC/trunk/lib/POE/Component/Server/JSONRPC.pm

    r276 r532  
    88use POE qw/ 
    99    Component::Server::TCP 
    10     Filter::Stackable 
    11     Filter::JSON 
    1210    Filter::Line 
    1311    /; 
     
    1614=head1 NAME 
    1715 
    18 POE::Component::Server::JSONRPC - Module abstract (<= 44 characters) goes here 
     16POE::Component::Server::JSONRPC - POE tcp based JSON-RPC server 
    1917 
    2018=head1 SYNOPSIS 
     
    4240=head1 DESCRIPTION 
    4341 
    44 Stub documentation for this module was created by ExtUtils::ModuleMaker. 
    45 It looks like the author of the extension was negligent enough 
    46 to leave the stub unedited. 
    47  
    48 Blah blah blah. 
     42This module is a POE component for tcp based JSON-RPC Server. 
     43 
     44The specification is defined on http://json-rpc.org/ and this module use JSON-RPC 1.0 spec (1.1 does not cover tcp streams) 
    4945 
    5046=head1 METHODS 
    5147 
    5248=head2 new 
     49 
     50Create JSONRPC component session and return the session id. 
     51 
     52Parameters: 
     53 
     54=over 
     55 
     56=item Port 
     57 
     58Port number for listen. 
     59 
     60=item Handler 
     61 
     62Hash variable contains handler name as key, handler poe state name as value. 
     63 
     64Handler name (key) is used as JSON-RPC method name. 
     65 
     66So if you send {"method":"echo"}, this module call the poe state named "echo". 
     67 
     68=back 
    5369 
    5470=cut 
     
    7288} 
    7389 
     90=head1 HANDLER PARAMETERS 
     91 
     92=over 
     93 
     94=item ARG0 
     95 
     96A session id of PoCo::Server::JSONRPC itself. 
     97 
     98=item ARG1 .. ARGN 
     99 
     100JSONRPC argguments 
     101 
     102=back 
     103 
     104ex) If you send following request 
     105 
     106    {"method":"echo", "params":["foo", "bar"]} 
     107 
     108then, "echo" handler is called and parameters is that ARG0 is component session id, ARG1 "foo", ARG2 "bar". 
     109 
     110=head1 HANDLER RESPONSE 
     111 
     112You must call either "result" or "error" state in your handlers to response result or error. 
     113 
     114ex: 
     115 
     116   $kernel->post( $component_session_id => "result" => "result value" ) 
     117 
     118$component_session_id is ARG0 in handler. If you do above, response is: 
     119 
     120   {"result":"result value", "error":""} 
     121 
     122 
    74123=head1 POE METHODS 
     124 
     125Inner method for POE states. 
    75126 
    76127=head2 poe__start