From 3fceb3649dab833c0c4d7acbac5ff7cf4d39cf57 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 28 May 2010 14:23:19 +0000 Subject: [PATCH] Optimized jsonRPC class git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18790 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_jsonRPC.inc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gosa-core/include/class_jsonRPC.inc b/gosa-core/include/class_jsonRPC.inc index 54f98096c..eae33f9bd 100644 --- a/gosa-core/include/class_jsonRPC.inc +++ b/gosa-core/include/class_jsonRPC.inc @@ -6,11 +6,12 @@ class jsonRPC { private $url; private $id; - public function __construct($url,$debug = false) { + public function __construct($url,$debug = false) + { $this->url = $url; - $this->dbug = $debug; - $this->id = 1; + $this->debug = $debug; + $this->id = 0; // Init Curl handler $this->curlHandler = curl_init($this->url); @@ -22,7 +23,13 @@ class jsonRPC { curl_setopt($this->curlHandler, CURLOPT_HTTPHEADER , array('Content-Type: application/json')); } - public function __call($method,$params) { + public function __destruct() + { + curl_close($this->curlHandler); + } + + public function __call($method,$params) + { if (!is_scalar($method)) trigger_error('jsonRPC::__call requires a scalar value as first parameter!'); @@ -43,9 +50,9 @@ class jsonRPC { // Check responce id if ($response['id'] != $this->id){ - trigger_error('jsonPRC returned incorrect response id (request id: '.$this->id.', response id: '.$response['id'].')'); + trigger_error('jsonPRC returned incorrect response '. + 'id (request id: '.$this->id.', response id: '.$response['id'].')'); } - return($response['result']); } } -- 2.30.2