|
NAMEEvent::RPC::Client - Client API to connect to Event::RPC ServersSYNOPSISuse Event::RPC::Client; my $rpc_client = Event::RPC::Client->new ( #-- Required arguments host => "localhost", port => 5555, #-- Optional arguments classes => [ "Event::RPC::Test" ], class_map => { "Event::RPC::Test" => "My::Event::RPC::Test" }, ssl => 1, ssl_ca_file => "some/ca.crt", ssl_ca_path => "some/ca/dir", timeout => 10, auth_user => "fred", auth_pass => Event::RPC->crypt("fred",$password), error_cb => sub { my ($client, $error) = @_; print "An RPC error occured: $error\n"; $client->disconnect; exit; }, ); $rpc_client->connect; #-- And now use classes and methods the server #-- allows to access via RPC, here My::TestModule #-- from the Event::RPC::Server manpage SYNPOSIS. my $obj = My::TestModule->new( data => "foobar" ); print "obj says hello: ".$obj->hello."\n"; $obj->set_data("new foobar"); print "updated data: ".$obj->get_data."\n"; $rpc_client->disconnect; DESCRIPTIONUse this module to write clients accessing objects and methods exported by a Event::RPC driven server.Just connect to the server over the network, optionally with SSL and user authentication, and then simply use the exported classes and methods like having them locally in the client. General information about the architecture of Event::RPC driven applications is collected in the Event::RPC manpage. The following documentation describes the client connection options in detail. CONFIGURATION OPTIONSYou need to specify at least the server hostname and TCP port to connect a Event::RPC server instance. If the server requires a SSL connection or user authentication you need to supply the corresponding options as well, otherwise connecting will fail.All options described here may be passed to the new() constructor of Event::RPC::Client. As well you may set or modify them using set_OPTION style mutators, but not after connect() was called! All options may be read using get_OPTION style accessors. REQUIRED OPTIONSThese are necessary to connect the server:
NETWORK OPTIONS
CLASS IMPORT OPTION
SSL OPTIONSIf the server accepts only SSL connections you need to enable ssl here in the client as well. By default the SSL connection will be established without any peer verification, which makes Man-in-the-Middle attacks possible. If you want to prevent that, you need to set either ssl_ca_file or ssl_ca_path option.
AUTHENTICATION OPTIONSIf the server requires user authentication you need to set the following options:
If the passed credentials are invalid the Event::RPC::Client->connect() method throws a correspondent exception. ERROR HANDLINGAny exceptions thrown on the server during execution of a remote method will result in a corresponding exception on the client. So you can use normal exception handling with eval {} when executing remote methods.But besides this the network connection between your client and the server may break at any time. This raises an exception as well, but you can override this behaviour with the following attribute:
METHODS
READY ONLY ATTRIBUTES
AUTHORSJörn Reder <joern at zyn dot de> COPYRIGHT AND LICENSECopyright (C) 2002-2006 by Joern Reder, All Rights Reserved.This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. POD ERRORSHey! The above document had some coding errors, which are explained below:
Visit the GSP FreeBSD Man Page Interface. |