| 
 
 NAMEEvent::RPC::Server - Simple API for event driven RPC servers SYNOPSIS  use Event::RPC::Server;
  use My::TestModule;
  my $server = Event::RPC::Server->new (
      #-- Required arguments
      port               => 8888,
      classes            => {
        "My::TestModule" => {
          new      => "_constructor",
          get_data => 1,
          set_data => 1,
          clone    => "_object",
        },
      },
      #-- Optional arguments
      name                => "Test server",
      logger              => Event::RPC::Logger->new(),
      start_log_listener  => 1,
      ssl                 => 1
      ssl_key_file        => "server.key",
      ssl_cert_file       => "server.crt",
      ssl_passwd_cb       => sub { "topsecret" },
      auth_required       => 1,
      auth_passwd_href    => { $user => Event::RPC->crypt($user,$pass) },
      auth_module         => Your::Own::Auth::Module->new(...),
      loop                => Event::RPC::Loop::Event->new(),
      
      host                => "localhost",
      load_modules        => 1,
      auto_reload_modules => 1,
      connection_hook     => sub { ... },
  );
  $server->start;
  # and later from inside your server implementation
  Event::RPC::Server->instance->stop;
DESCRIPTIONUse this module to add a simple to use RPC mechanism to your event driven server application. Just create an instance of the Event::RPC::Server class with a bunch of required settings. Then enter the main event loop through it, or take control over the main loop on your own if you like (refer to the MAINLOOP chapter for details). General information about the architecture of Event::RPC driven applications is collected in the Event::RPC manpage. CONFIGURATION OPTIONSAll options described here may be passed to the new() constructor of Event::RPC::Server. As well you may set or modify them using set_OPTION style mutators, but not after start() or setup_listeners() was called! All options may be read using get_OPTION style accessors. REQUIRED OPTIONSIf you just pass the required options listed beyond you have a RPC server which listens to a network port and allows everyone connecting to it to access a well defined list of classes and methods resp. using the correspondent server objects. There is no authentication or encryption active in this minimal configuration, so aware that this may be a big security risk! Adding security is easy, refer to the chapters about SSL and authentication. These are the required options: 
 
 SSL OPTIONSThe client/server protocol of Event::RPC is not encrypted by default, so everyone listening on your network can read or even manipulate data. To prevent this efficiently you can enable SSL encryption. Event::RPC uses the IO::Socket::SSL Perl module for this. First you need to generate a server key and certificate for your server using the openssl command which is part of the OpenSSL distribution, e.g. by issueing these commands (please refer to the manpage of openssl for details - this is a very rough example, which works in general, but probably you want to tweak some parameters):   % openssl genrsa -des3 -out server.key 1024
  % openssl req -new -key server.key -out server.csr
  % openssl x509 -req -days 3600 -in server.csr \
            -signkey server.key -out server.crt
After executing these commands you have the following files server.crt server.key server.csr Event::RPC needs the first two of them to operate with SSL encryption. To enable SSL encryption you need to pass the following options to the constructor: 
 AUTHENTICATION OPTIONSSSL encryption is fine, now it's really hard for an attacker to listen or modify your network communication. But without any further configuration any user on your network is able to connect to your server. To prevent this users resp. connections to your server needs to be authenticated somehow. Since version 0.87 Event::RPC has an API to delegate authentication tasks to a module, which can be implemented outside Event::RPC. To be compatible with prior releases it ships the module Event::RPC::AuthPasswdHash which implements the old behaviour transparently. This default implementation is a simple user/password based model. For now this controls just the right to connect to your server, so knowing one valid user/password pair is enough to access all exported methods of your server. Probably a more differentiated model will be added later which allows granting access to a subset of exported methods only for each user who is allowed to connect. The following options control the authentication: 
 Note: you can use the authentication module without SSL but aware that an attacker listening to the network connection will be able to grab the encrypted password token and authenticate himself with it to the server (replay attack). Probably a more sophisticated challenge/response mechanism will be added to Event::RPC to prevent this. But you definitely should use SSL encryption in a critical environment anyway, which renders grabbing the password from the net impossible. LOGGING OPTIONSEvent::RPC has some logging abilities, primarily for debugging purposes. It uses a logger for this, which is an object implementing the Event::RPC::Logger interface. The documentation of Event::RPC::Logger describes this interface and Event::RPC's logging facilities in general. 
 MAINLOOP OPTIONSEvent::RPC derived it's name from the fact that it follows the event driven paradigm. There are several toolkits for Perl which allow event driven software development. Event::RPC has an abstraction layer for this and thus should be able to work with any toolkit. 
 If you use the Event::RPC->start() method as described in the SYNOPSIS Event::RPC will enter the correspondent main loop for you. If you want to have full control over the main loop, use this method to setup all necessary Event::RPC listeners: $rpc_server->setup_listeners(); and manage the main loop stuff on your own. MISCELLANEOUS OPTIONS
 METHODSThe following methods are publically available: 
 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: 
 
 
  |