1 | <?php |
||
40 | class Server extends Application implements ServerInterface |
||
41 | { |
||
42 | use TimersAware; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | const LOGO = <<<EOT |
||
48 | _____ _____ _ _ _ _____ _____ |
||
49 | / ___/ | _ \ | | | | / / | ____| | _ \ |
||
50 | | |___ | |_| | | | | |/ / | |__ | | | | |
||
51 | \___ \ | ___/ | | | |\ \ | __| | | | | |
||
52 | ___| | | | | | | | \ \ | |___ | |_| | |
||
53 | /_____/ |_| |_| |_| \_\ |_____| |_____/ |
||
54 | |||
55 | |||
56 | EOT; |
||
57 | |||
58 | const NAME = 'Spike Server'; |
||
59 | |||
60 | const VERSION = '0.0.1'; |
||
61 | |||
62 | /** |
||
63 | * @var Configuration |
||
64 | */ |
||
65 | protected $configuration; |
||
66 | |||
67 | /** |
||
68 | * @var LoopInterface |
||
69 | */ |
||
70 | protected $eventLoop; |
||
71 | |||
72 | /** |
||
73 | * @var ChunkServerInterface[]|ChunkServerCollection |
||
74 | */ |
||
75 | protected $chunkServers; |
||
76 | |||
77 | /** |
||
78 | * @var ClientInterface[]|Collection |
||
79 | */ |
||
80 | protected $clients; |
||
81 | |||
82 | /** |
||
83 | * @var DispatcherInterface |
||
84 | */ |
||
85 | protected $eventDispatcher; |
||
86 | |||
87 | /** |
||
88 | * @var Logger |
||
89 | */ |
||
90 | protected $logger; |
||
91 | |||
92 | public function __construct(Configuration $configuration, LoopInterface $eventLoop = null) |
||
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | public function getHelp() |
||
110 | |||
111 | /** |
||
112 | * {@inheritdoc} |
||
113 | */ |
||
114 | public function doRun(InputInterface $input, OutputInterface $output) |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | * |
||
137 | * @codeCoverageIgnore |
||
138 | */ |
||
139 | public function start() |
||
150 | |||
151 | /** |
||
152 | * {@inheritdoc} |
||
153 | */ |
||
154 | public function stopClient(ClientInterface $client) |
||
171 | |||
172 | /** |
||
173 | * Handle control connection. |
||
174 | * |
||
175 | * @param ConnectionInterface $connection |
||
176 | */ |
||
177 | public function handleControlConnection(ConnectionInterface $connection) |
||
215 | |||
216 | /** |
||
217 | * {@inheritdoc} |
||
218 | */ |
||
219 | public function getChunkServers() |
||
223 | |||
224 | /** |
||
225 | * @return LoopInterface |
||
226 | */ |
||
227 | public function getEventLoop() |
||
231 | |||
232 | /** |
||
233 | * {@inheritdoc} |
||
234 | */ |
||
235 | public function getEventDispatcher() |
||
239 | |||
240 | /** |
||
241 | * @return Configuration |
||
242 | */ |
||
243 | public function getConfiguration() |
||
247 | |||
248 | /** |
||
249 | * Gets all clients. |
||
250 | * |
||
251 | * @return Collection|ClientInterface[] |
||
252 | */ |
||
253 | public function getClients() |
||
257 | |||
258 | /** |
||
259 | * Gets the client by ID. |
||
260 | * |
||
261 | * @param string $id |
||
262 | * |
||
263 | * @return null|ClientInterface |
||
264 | */ |
||
265 | public function getClientById($id) |
||
271 | |||
272 | /** |
||
273 | * @return Logger |
||
274 | */ |
||
275 | public function getLogger() |
||
279 | |||
280 | protected function initializeEvents() |
||
285 | |||
286 | /** |
||
287 | * Creates default timers. |
||
288 | * |
||
289 | * @codeCoverageIgnore |
||
290 | */ |
||
291 | protected function initializeTimers() |
||
297 | |||
298 | /** |
||
299 | * {@inheritdoc} |
||
300 | */ |
||
301 | protected function getDefaultCommands() |
||
307 | |||
308 | /** |
||
309 | * {@inheritdoc} |
||
310 | */ |
||
311 | protected function getDefaultInputDefinition() |
||
321 | } |
||
322 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: