| include_once $GLOBALS['THRIFT_ROOT'].'/server/TServer.php'; |
| * Simple implemtation of a Thrift server. |
| class TSimpleServer extends TServer { |
| * Flag for the main serving loop |
| * Listens for new client using the supplied |
| * transport. It handles TTransportExceptions |
| * to avoid timeouts etc killing it |
| public function serve() { |
| $this->transport_->listen(); |
| $transport = $this->transport_->accept(); |
| if ($transport != null) { |
| $inputTransport = $this->inputTransportFactory_->getTransport($transport); |
| $outputTransport = $this->outputTransportFactory_->getTransport($transport); |
| $inputProtocol = $this->inputProtocolFactory_->getProtocol($inputTransport); |
| $outputProtocol = $this->outputProtocolFactory_->getProtocol($outputTransport); |
| while ($this->processor_->process($inputProtocol, $outputProtocol)) { } |
| catch (TTransportException $e) { } |
| * Stops the server running. Kills the transport |
| * and then stops the main serving loop |
| $this->transport_->close(); |