Esempio n. 1
0
 /**
  * Called when I\O isn't happening to process RPC queue.
  * 
  * This should only be called by the event loop.
  * 
  * @param \EvIdle $watcher
  * @param integer $revents
  * @return void
  */
 public function _onIdle(\EvIdle $watcher, $revents)
 {
     // Get the first RPC in the queue.
     $rpc = array_shift($this->rpc_queue);
     if (!$rpc instanceof Rpc) {
         return $watcher->stop();
     }
     // Make method call.
     $method_name = self::ACTION_METHOD_PREFIX . ucfirst(strtolower($rpc->type));
     if (method_exists($this, $method_name)) {
         $rpc->response = call_user_func(array($this, $method_name), $rpc->name, $rpc->arguments);
     }
     // Add the data to the output queue to return response to parent process.
     $this->response_queue[] = serialize($rpc);
     // Make sure the output pipe watcher is runnning to dump queue contents.
     if (!$this->watchers[1]->is_active) {
         $this->watchers[1]->start();
     }
     return true;
 }