예제 #1
0
 /**
  * Starts the server.
  */
 public function run()
 {
     $this->redis_server->del($this->message_queue);
     $timeout = 0;
     while (1) {
         # Pop a message from the queue.
         # Decode the message.
         # Check that the function exists.
         list($message_queue, $message) = $this->redis_server->blpop($this->message_queue, $timeout);
         assert($message_queue == $this->message_queue);
         debug_print("RPC Request: {$message}");
         $rpc_request = json_decode($message);
         $response_queue = $rpc_request->response_queue;
         $function_call = FunctionCall::from_object($rpc_request->function_call);
         if (!method_exists($this->local_object, $function_call->name)) {
             $rpc_response = array('exception' => 'method "' . $function_call->name . '" does not exist');
         } else {
             $code = 'return $this->local_object->' . $function_call->as_php_code() . ';';
             debug_print($code);
             try {
                 $return_value = eval($code);
                 $rpc_response = array('return_value' => $return_value);
             } catch (Exception $e) {
                 $rpc_response = array('exception' => $e->getMessage());
             }
         }
         $message = json_encode($rpc_response);
         debug_print("RPC Response: {$message}");
         $this->redis_server->rpush($response_queue, $message);
     }
 }
예제 #2
0
파일: AST.php 프로젝트: koolkode/expression
 public function __construct(Node $input, string $name, array $args)
 {
     parent::__construct($name, $args);
     $this->input = $input;
 }