NAME
XAS::Lib::RPC::JSON::Server - A simple JSON RPC server
SYNOPSIS
my $server = XAS::Lib::RPC::JSON::Server->new(
-alias => 'server',
-port => '9505',
-address => 'localhost',
-logger => 'logger'
);
DESCRIPTION
This modules implements a simple JSON RPC v2.0 server. It needs to be extended to be useful. This runs as a POE session. It doesn't support "Notification" calls. It inherits from XAS::Lib::Net::Server.
METHODS
new
This initializes the module and starts listening for requests. There are five parameters that can be passed. They are the following:
- -alias
-
The name of the POE session.
- -port
-
The IP port to listen on (default 9505).
- -address
-
The address to bind to (default 127.0.0.1).
- -logger
-
The name of the logger session.
methods
A handle to a Set::Light object that contains the methods that can be evoked.
PUBLIC EVENTS
Events are used to handle processing.
process_request($kernel, $self, $input, $ctx)
This method will attempt to parse the JSON RPC request packet and call the correct RPC method.
- $kernel
-
The handle to the POE kernel.
- $self
-
The handle to the current object.
- $input
-
The input to parse and create a json packet from.
- $ctx
-
The context of this call.
process_response($kernel, $self, $input, $ctx)
This method will attempt to parse the response and return the correct JSON RPC results packet to the client.
- $kernel
-
The handle to the POE kernel.
- $self
-
The handle to the current object.
- $output
-
The out to parse and create a json response from.
- $ctx
-
The context of this call.
process_errors($kernel, $self, $output, $ctx)
This method will attempt to parse the response and return the correct JSON RPC error packet to the client.
- $kernel
-
The handle to the POE kernel.
- $self
-
The handle to the current object.
- $output
-
The output to parse and create a json response from. This needs to have "code" and "message" fields.
- $ctx
-
The context of this call.
SEE ALSO
AUTHOR
Kevin L. Esteb, <kevin@kesteb.us>
COPYRIGHT AND LICENSE
Copyright (C) 2012 by Kevin L. Esteb
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.