public function recv_gen_id() { $bin_accel = $this->input_ instanceof Thrift\Protocol\TProtocol::$TBINARYPROTOCOLACCELERATED && function_exists('thrift_protocol_read_binary'); if ($bin_accel) { $result = thrift_protocol_read_binary($this->input_, '\\generator_service_gen_id_result', $this->input_->isStrictRead()); } else { $rseqid = 0; $fname = null; $mtype = 0; $this->input_->readMessageBegin($fname, $mtype, $rseqid); if ($mtype == Thrift\Type\TMessageType::EXCEPTION) { $x = new Thrift\Exception\TApplicationException(); $x->read($this->input_); $this->input_->readMessageEnd(); throw $x; } $result = new generator_service_gen_id_result(); $result->read($this->input_); $this->input_->readMessageEnd(); } if ($result->success !== null) { return $result->success; } throw new \Exception("gen_id failed: unknown result"); }
/** * 将异常写会客户端 * @param string $name * @param Exception $e * @param string $protocol */ private function writeExceptionToClient($name, $e, $protocol = 'Thrift\\Protocol\\TBinaryProtocol') { try { $ex = new \Thrift\Exception\TApplicationException($e); $thriftsocket = new \Thrift\Transport\TBufferSocket(); $thriftsocket->setHandle($this->connections[$this->currentDealFd]); $framedTrans = new \Thrift\Transport\TFramedTransport($thriftsocket, true, true); $protocol = new $protocol($framedTrans, false, false); $protocol->writeMessageBegin($name, \Thrift\Type\TMessageType::EXCEPTION, 0); $ex->write($protocol); $protocol->writeMessageEnd(); $protocol->getTransport()->flush(); } catch (Exception $e) { } }