RPC::Lite::Client - Lightweight RPC client framework.
use RPC::Lite::Client; my $client = RPC::Lite::Client->new( { Transport => 'TCP:Host=blah.foo.com,Port=10000', Serializer => 'JSON', # JSON is actually the default, # this argument is unnecessary } ); my $result = $client->Request('HelloWorld');
RPC::Lite::Client implements a very lightweight remote process communications client framework. It can use arbitrary Transport (RPC::Lite::Transport) and Serialization (RPC::Lite::Serializer) mechanisms.
new
Creates a new RPC::Lite::Client object. Takes a hash reference of arguments.
A string specifying the RPC::Lite::Serializer to use when communicating with the server. See 'perldoc RPC::Lite::Serializers' for a list of supported serializers.
A string specifying the transport layer to use to connect to the server. The string is of the format:
<transport type>[:[<argument>=<value>[,<argument>=<value>...]]]
Eg, for a TCP connection to the host 'blah.foo.com' on port 10000:
TCP:Host=blah.foo.com,Port=10000
See 'perldoc RPC::Lite::Transports' for a list of supported transport mechanisms.
A boolean value indicating whether or not you wish to connect manually, rather than at object instantiation. If set to true, you are required to call Connect() on the client object before attempting to make requests.
If true, errors from the server will die(). If false, a warning will be emitted (warn()) and undef will be returned from Request. True by default.
Request
Connect()
Explicitly connects to the server. If this method is not called, the client will attempt to automatically connect when the first request is sent.
Request($methodName[, param[, ...]])
Sends a request to the server. Returns a native object that is the result of the request.
AsyncRequest($callBack, $methodName[, param[, ...]])
Sends an asynchronous request to the server. Takes a callback code reference. After calling this, you'll probably want to call HandleResponse in a loop to check for a response from the server, at which point your callback will be executed and passed a native object which is the result of the call.
RequestResponseObject($methodName[, param[, ...]])
Sends a request to the server. Returns an RPC::Lite::Response object.
May be mixed in with calls to AsyncRequest. Not threadsafe.
AsyncRequestResponseObject($callBack, $methodName[, param[, ...]])
Sends an asynchronous request to the server. Takes a callback code reference. After calling this, you'll probably want to call HandleResponse in a loop to check for a response from the server, at which point your callback will be executed and passed an RPC::Lite::Response object holding the result of the call.
Notify($methodName[, param[, ...]])
Sends a 'notification' to the server. That is, it makes a request, but expects no response.
HandleResponse([$timeout])
Checks for a response from the server. Useful mostly in conjunction with AsyncRequest. You can pass a timeout, or the Transport's default timeout will be used. Returns an Error object if there was an error, otherwise returns undef.
1 POD Error
The following errors were encountered while parsing the POD:
You can't have =items (as at line 60) unless the first thing after the =over is an =item
=over without closing =back
To install RPC::Lite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPC::Lite
CPAN shell
perl -MCPAN -e shell install RPC::Lite
For more information on module installation, please visit the detailed CPAN module installation guide.