myID = getmypid(); // var_dump($consts); if (!isset($consts->requestQueueName)) { $this->requestQueueName = constant(get_class($consts)."::REQUEST_QUEUE_NAME"); $this->replyQueueName = constant(get_class($consts)."::REPLY_QUEUE_NAME"); } else { $this->requestQueueName = $consts->requestQueueName; $this->replyQueueName = $consts->replyQueueName; } $this->requestQ = new Shm_Message_Queue($this->requestQueueName); $this->responseQ = new Shm_Message_Queue($this->replyQueueName); } private function __clone() {} public static function getInstance($name, $consts = NULL) { if (RPCClient::$instances[$name] === NULL) { if (!is_object($consts)) { throw new Exception("Second parameter is not an object"); } RPCClient::$instances[$name] = new RPCClient($consts); RPCClient::$instances[$name]->servantName = $name; } return RPCClient::$instances[$name]; } public static function getInstanceByName($registeredName, $name) { if (self::$nameService === NULL) { throw new Exception(sprintf("No setting for the name service! Use %s::setNameService()", __CLASS__)); } if (RPCClient::$instances[$name] === NULL) { $consts = self::$nameService->getServermetadataForServantName($registeredName); RPCClient::$instances[$name] = new RPCClient($consts); RPCClient::$instances[$name]->servantName = $registeredName; } return RPCClient::$instances[$name]; } public static function setNameService($consts) { self::$nameService = RPCClient::getInstance('NameService', $consts); } public function __call($method, $parameters) { $requestObj = new RPCRequest(); $requestObj->setCallerID($this->myID); $requestObj->setServantName($this->servantName); $requestObj->setMethodName($method); $requestObj->setParameters($parameters); // var_dump($parameters); // var_dump("Sending", $requestObj, "with ID :".getmypid()); $this->requestQ->send($requestObj); if ($this->syncCall) { $status = $this->responseQ->receive(array('desired_message_type'=>$this->myID)); if ($status) { $responseObj = $this->responseQ->getRecvMsg(); return $responseObj->getResult(); } else { throw new Exception('Error while receiving response'); } } }// __call } ?>