Joshua N Pritikin wrote: > Hrm, sounds interesting. > > So what does Event::RPC do exactly? Can you post a summary?
Yep, here it is: --snip-- Summary of Event::RPC ===================== Event::RPC consists of a server and a client library. The server exports a list of modules and methods, which are allowed to be called over the network. More specific it acts as a proxy for objects created on the server side (on demand of the connected clients) which handles client side methods calls with transport of method arguments and return values. The server side object proxy handles refcounting and destruction of objects created by clients properly. Objects as method parameters and return values are handled as well. For the client the whole thing is totally transparent - once connected to the server it doesn't know whether it calls methods on local or remote objects. This is a simple example to make clear how this works: Server: ================================================== use strict; use Event::RPC::Server; main: { #-- Create a Server instance and declare the #-- exported interface my $server = Event::RPC::Server->new ( name => "test daemon", port => 5555, classes => { 'Event::RPC::Test' => { new => '_constructor', # Class constructor set_data => 1, # and 'normal' methods... get_data => 1, hello => 1, }, }, ); #-- Start the server resp. the Event loop. $server->start; } #-- A simple test class package Event::RPC::Test; sub get_data { shift->{data} } sub set_data { shift->{data} = $_[1] } sub new { my $class = shift; my %par = @_; my ($data) = $par{'data'}; my $self = bless { data => $data }; return $self; } sub hello { my $self = shift; return "I have this data: '".$self->get_data."'"; } Client: ================================================== use strict; use Event::RPC::Client; main: { #-- This connects to the server, requests the exported #-- interfaces and establishes proxy methods #-- in the correspondent packages. my $client = Event::RPC::Client->connect ( server => "localhost", port => 5555, error_cb => sub { print "An RPC error occured\n"; exit }, ); #-- From now on the call to Event::RPC::Test->new is handled #-- transparently by Event::RPC::Client my $object = Event::RPC::Test->new ( data => "some test data" x 5 ); #-- and method calls as well... print "hello=".$object->hello,"\n"; $object->set_data ("changed data"); print "data=".$object->get_data."\n"; #-- disconnection is handled by the destructor of $client } --snip-- Regards, Joern -- Think before you code. And while you're doing it probably won't hurt. ;)
pgpaVWBjjNd1A.pgp
Description: PGP signature