I'm working on a scheme to make remote access to persistent Perl objects simple. I'm writing to ask for advice of all kinds, including naming and functionality.
UPSHOT of my approach The class being exposed doesn't even know. The client knows the classes are remote, but only has to mention it in the initial use statement for the somewhat magical RemoteObject class. The client stays connected to the server until all of its RemoteObjects to the server go out of scope. I've provided server and client examples below. The codes run using perl 5.6.1, POE 0.24, on Cygwin under Windows 2000 and on Redhat Linux 7.1. They rely on modules not shown. Here's a server: use OOPersistServer; my $server = OOPersistServer->new( Alias => "averages_service", Port => "13241", ExposedClasses => [ { Package => "Averages", DocAddress => "http://server.company.com/Averages.html", }, { Package => "DiePair", DocAddress => "http://server.company.com/DiePair.html", }, ], ); $server->start(); Averages.pm and DiePair.pm are small object oriented modules. [Averages takes a list of numbers and returns the mean, median, or modes upon subsequent requests. DiePair aggregates two Die objects (implemented in Die.pm) providing a roll method and methods to check the roll result.] Both of these modules are teaching examples I wrote before thinking of the current scheme. They have no idea they are being accessed remotely. Here's a client: use RemoteObject 'localhost:13241' => [ qw(Averages DiePair) ]; my $averager = Averages->new( 3, 4, 7); my @modes = $averager->mode(); print "modes: @modes\n"; print RemoteObject->send_documentation("DiePair") . "\n"; my $dice = DiePair->new(6, 6); $dice->roll(); my $total = $dice->total(); my $doubles = $dice->was_it_doubles(); print "roll: $total "; if ($doubles) { print "it was doubles\n"; } else { print "it wasn't doubles\n"; } MORE DETAILS The server wraps a POE::Component::Server::TCP. Calling start on the server object passes the request on as $poe_kernel->run();. I don't think clients can use POE directly. The problem is that client scripts can't be made to handle event callbacks. So, my client uses IO::Socket directly. The clients stay connected until their RemoteObject goes out of scope (usually when the script dies). MY QUESTIONS Is anyone interested in this aggressive simplification of client and server API's? Would a server helper module like OOPersistServer be a candidate to be a genuine POE::Component::Server? If this were your code, how would you name the pieces for CPAN? Thanks, Phil __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com