コード例 #1
0
ファイル: Server.php プロジェクト: cjq/thrift-rpc-server
 public function onReceive($serv, $fd, $from_id, $data)
 {
     $processor_class = "\\Services\\" . $this->serviceName . "\\" . $this->serviceName . 'Processor';
     $handler_class = "\\Services\\" . $this->serviceName . "\\Handler";
     $handler = new $handler_class();
     $this->processor = new $processor_class($handler);
     $socket = new Socket();
     $socket->setHandle($fd);
     $socket->buffer = $data;
     $socket->server = $serv;
     $protocol = new Thrift\Protocol\TBinaryProtocol($socket, false, false);
     try {
         $protocol->fname = $this->serviceName;
         $this->processor->process($protocol, $protocol);
     } catch (\Exception $e) {
         $this->notice('CODE:' . $e->getCode() . ' MESSAGE:' . $e->getMessage() . "\n" . $e->getTraceAsString());
     }
 }
コード例 #2
0
ファイル: Server.php プロジェクト: higherchen/rpc
 public function onReceive($serv, $fd, $from_id, $data)
 {
     $config = Di::get('config');
     $processor_class = $config['processor'];
     $handler_class = $config['handler'];
     $handler = new $handler_class();
     $processor = new $processor_class($handler);
     $socket = new Socket();
     $socket->setHandle($fd);
     $socket->buffer = $data;
     $socket->server = $serv;
     $protocol = new Thrift\Protocol\TBinaryProtocol($socket, false, false);
     try {
         $protocol->fname = $config['name'];
         $processor->process($protocol, $protocol);
     } catch (\Exception $e) {
         Logger::write(date('Y-m-d H:i:s') . ' [' . $e->getCode() . '] ' . $e->getMessage() . PHP_EOL);
     }
 }