• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/WebServices/RPC/classes/class.ilRPCServerAdapter.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00033 define("RPC_TIMEOUT",0);
00034 
00035 include_once('Services/WebServices/RPC/classes/class.ilRPCServerSettings.php');
00036 
00037 class ilRPCServerAdapter
00038 {
00039         var $response_timeout = RPC_TIMEOUT;
00040         var $log = null;
00041         var $db = null;
00042         var $err = null;
00043 
00044         var $settings_obj  = null;
00045 
00046         var $rpc_client = null;
00047         var $rpc_message = null;
00048 
00049         function ilRPCServerAdapter()
00050         {
00051                 global $ilLog,$ilDB,$ilErr;
00052 
00053                 $this->log =& $ilLog;
00054                 $this->db =& $ilDB;
00055                 $this->err =& $ilErr;
00056 
00057                 $this->__checkPear();
00058 
00059                 $this->settings_obj =& new ilRPCServerSettings();
00060         }
00061         
00062         function setResponseTimeout($a_response_timeout)
00063         {
00064                 $this->response_timeout = $a_response_timeout;
00065         }
00066 
00074         function &send()
00075         {
00076                 include_once 'XML/RPC.php';
00077                 if(!$response =& $this->rpc_client->send($this->rpc_message,$this->response_timeout))
00078                 {
00079                         $this->log->write("ilRPCServerAdapter: Communication error");
00080                         return null;
00081                 }
00082                 if($response->faultCode())
00083                 {
00084                         $this->log->write("ilRPCServerAdapter: Communication error: ". $response->faultString());
00085                         return null;
00086                 }
00087                 return XML_RPC_decode($response->value());
00088         }
00089         // PRIVATE
00090         function __checkPear()
00091         {
00092                 if(!include_once('XML/RPC.php'))
00093                 {
00094                         $this->log->write('ilLuceneRPCAdapter(): Cannot find pear library XML_RPC. Aborting');
00095                         $this->err->raiseError("Cannot find pear package 'XML_RPC'. Aborting ",$this->err->MESSAGE);
00096                 }
00097                 return true;
00098         }
00099 
00107         function __initClient()
00108         {
00109                 include_once 'XML/RPC.php';
00110 
00111                 $this->rpc_client =& new XML_RPC_Client($this->settings_obj->getPath(),
00112                                                                                                 $this->settings_obj->getHost(),
00113                                                                                                 $this->settings_obj->getPort());
00114                 #$this->rpc_client->setDebug(1);
00115 
00116                 return true;
00117         }
00118 
00119 
00129         function __initMessage($a_message_name,$params)
00130         {
00131                 include_once 'XML/RPC.php';
00132                 
00133                 $this->rpc_message =& new XML_RPC_Message($a_message_name,$params);
00134                 
00135                 // We create the payload here since it might be quite time consuming 
00136                 // and this could cause a socket read exception on the server side.
00137                 $this->rpc_message->createPayload();
00138 
00139                 return true;
00140         }
00141 }
00142 ?>

Generated on Fri Dec 13 2013 17:57:02 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1