TServerTransport.php 931 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Thrift\Server;
  3. use Thrift\Exception\TTransportException;
  4. /**
  5. * Generic class for Server agent.
  6. *
  7. * @package thrift.transport
  8. */
  9. abstract class TServerTransport
  10. {
  11. /**
  12. * List for new clients
  13. *
  14. * @abstract
  15. * @return void
  16. */
  17. abstract public function listen();
  18. /**
  19. * Close the server
  20. *
  21. * @abstract
  22. * @return void
  23. */
  24. abstract public function close();
  25. /**
  26. * Subclasses should use this to implement
  27. * accept.
  28. *
  29. * @abstract
  30. * @return TTransport
  31. */
  32. abstract protected function acceptImpl();
  33. /**
  34. * Uses the accept implemtation. If null is returned, an
  35. * exception is thrown.
  36. *
  37. * @throws TTransportException
  38. * @return TTransport
  39. */
  40. public function accept()
  41. {
  42. $transport = $this->acceptImpl();
  43. if ($transport == null) {
  44. throw new TTransportException("accept() may not return NULL");
  45. }
  46. return $transport;
  47. }
  48. }