1 | <?php |
||
39 | class Server extends Application implements ServerInterface |
||
40 | { |
||
41 | use TimersAware; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | const LOGO = <<<EOT |
||
47 | _____ _____ _ _ _ _____ _____ |
||
48 | / ___/ | _ \ | | | | / / | ____| | _ \ |
||
49 | | |___ | |_| | | | | |/ / | |__ | | | | |
||
50 | \___ \ | ___/ | | | |\ \ | __| | | | | |
||
51 | ___| | | | | | | | \ \ | |___ | |_| | |
||
52 | /_____/ |_| |_| |_| \_\ |_____| |_____/ |
||
53 | |||
54 | |||
55 | EOT; |
||
56 | |||
57 | const NAME = 'Spike Server'; |
||
58 | |||
59 | const VERSION = '0.0.1'; |
||
60 | |||
61 | /** |
||
62 | * @var Configuration |
||
63 | */ |
||
64 | protected $configuration; |
||
65 | |||
66 | /** |
||
67 | * @var LoopInterface |
||
68 | */ |
||
69 | protected $eventLoop; |
||
70 | |||
71 | /** |
||
72 | * @var ChunkServerInterface[]|ChunkServerCollection |
||
73 | */ |
||
74 | protected $chunkServers; |
||
75 | |||
76 | /** |
||
77 | * @var ClientInterface[]|Collection |
||
78 | */ |
||
79 | protected $clients; |
||
80 | |||
81 | /** |
||
82 | * @var DispatcherInterface |
||
83 | */ |
||
84 | protected $eventDispatcher; |
||
85 | |||
86 | /** |
||
87 | * @var Logger |
||
88 | */ |
||
89 | protected $logger; |
||
90 | |||
91 | public function __construct(Configuration $configuration, LoopInterface $eventLoop = null) |
||
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | public function getHelp() |
||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | public function doRun(InputInterface $input, OutputInterface $output) |
||
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | * |
||
136 | * @codeCoverageIgnore |
||
137 | */ |
||
138 | public function start() |
||
149 | |||
150 | /** |
||
151 | * {@inheritdoc} |
||
152 | */ |
||
153 | public function stopClient(ClientInterface $client, $closedBy = null) |
||
171 | |||
172 | /** |
||
173 | * Handle control connection. |
||
174 | * |
||
175 | * @param ConnectionInterface $connection |
||
176 | */ |
||
177 | public function handleControlConnection(ConnectionInterface $connection) |
||
216 | |||
217 | /** |
||
218 | * {@inheritdoc} |
||
219 | */ |
||
220 | public function getChunkServers() |
||
224 | |||
225 | /** |
||
226 | * @return LoopInterface |
||
227 | */ |
||
228 | public function getEventLoop() |
||
232 | |||
233 | /** |
||
234 | * {@inheritdoc} |
||
235 | */ |
||
236 | public function getEventDispatcher() |
||
240 | |||
241 | /** |
||
242 | * @return Configuration |
||
243 | */ |
||
244 | public function getConfiguration() |
||
248 | |||
249 | /** |
||
250 | * Gets all clients. |
||
251 | * |
||
252 | * @return Collection|ClientInterface[] |
||
253 | */ |
||
254 | public function getClients() |
||
258 | |||
259 | /** |
||
260 | * Gets the client by ID. |
||
261 | * |
||
262 | * @param string $id |
||
263 | * |
||
264 | * @return null|ClientInterface |
||
265 | */ |
||
266 | public function getClientById($id) |
||
272 | |||
273 | /** |
||
274 | * @return Logger |
||
275 | */ |
||
276 | public function getLogger() |
||
280 | |||
281 | protected function initializeEvents() |
||
286 | |||
287 | /** |
||
288 | * Creates default timers. |
||
289 | * |
||
290 | * @codeCoverageIgnore |
||
291 | */ |
||
292 | protected function initializeTimers() |
||
298 | |||
299 | /** |
||
300 | * {@inheritdoc} |
||
301 | */ |
||
302 | protected function getDefaultCommands() |
||
308 | |||
309 | /** |
||
310 | * {@inheritdoc} |
||
311 | */ |
||
312 | protected function getDefaultInputDefinition() |
||
322 | } |
||
323 |
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: