]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | <?php |
2 | ||
3 | namespace Thrift\Server; | |
4 | ||
5 | use Thrift\Factory\TTransportFactory; | |
6 | use Thrift\Factory\TProtocolFactory; | |
7 | ||
8 | /** | |
9 | * Generic class for a Thrift server. | |
10 | * | |
11 | * @package thrift.server | |
12 | */ | |
13 | abstract class TServer | |
14 | { | |
15 | /** | |
16 | * Processor to handle new clients | |
17 | * | |
18 | * @var TProcessor | |
19 | */ | |
20 | protected $processor_; | |
21 | ||
22 | /** | |
23 | * Server transport to be used for listening | |
24 | * and accepting new clients | |
25 | * | |
26 | * @var TServerTransport | |
27 | */ | |
28 | protected $transport_; | |
29 | ||
30 | /** | |
31 | * Input transport factory | |
32 | * | |
33 | * @var TTransportFactory | |
34 | */ | |
35 | protected $inputTransportFactory_; | |
36 | ||
37 | /** | |
38 | * Output transport factory | |
39 | * | |
40 | * @var TTransportFactory | |
41 | */ | |
42 | protected $outputTransportFactory_; | |
43 | ||
44 | /** | |
45 | * Input protocol factory | |
46 | * | |
47 | * @var TProtocolFactory | |
48 | */ | |
49 | protected $inputProtocolFactory_; | |
50 | ||
51 | /** | |
52 | * Output protocol factory | |
53 | * | |
54 | * @var TProtocolFactory | |
55 | */ | |
56 | protected $outputProtocolFactory_; | |
57 | ||
58 | /** | |
59 | * Sets up all the factories, etc | |
60 | * | |
61 | * @param object $processor | |
62 | * @param TServerTransport $transport | |
63 | * @param TTransportFactory $inputTransportFactory | |
64 | * @param TTransportFactory $outputTransportFactory | |
65 | * @param TProtocolFactory $inputProtocolFactory | |
66 | * @param TProtocolFactory $outputProtocolFactory | |
67 | * @return void | |
68 | */ | |
69 | public function __construct( | |
70 | $processor, | |
71 | TServerTransport $transport, | |
72 | TTransportFactory $inputTransportFactory, | |
73 | TTransportFactory $outputTransportFactory, | |
74 | TProtocolFactory $inputProtocolFactory, | |
75 | TProtocolFactory $outputProtocolFactory | |
76 | ) { | |
77 | $this->processor_ = $processor; | |
78 | $this->transport_ = $transport; | |
79 | $this->inputTransportFactory_ = $inputTransportFactory; | |
80 | $this->outputTransportFactory_ = $outputTransportFactory; | |
81 | $this->inputProtocolFactory_ = $inputProtocolFactory; | |
82 | $this->outputProtocolFactory_ = $outputProtocolFactory; | |
83 | } | |
84 | ||
85 | /** | |
86 | * Serves the server. This should never return | |
87 | * unless a problem permits it to do so or it | |
88 | * is interrupted intentionally | |
89 | * | |
90 | * @abstract | |
91 | * @return void | |
92 | */ | |
93 | abstract public function serve(); | |
94 | ||
95 | /** | |
96 | * Stops the server serving | |
97 | * | |
98 | * @abstract | |
99 | * @return void | |
100 | */ | |
101 | abstract public function stop(); | |
102 | } |