1 | <?php |
||
36 | class Client extends Application implements ClientInterface |
||
37 | { |
||
38 | use TimersAware; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | const LOGO = <<<EOT |
||
44 | _____ _____ _ _ _ _____ |
||
45 | / ___/ | _ \ | | | | / / | ____| |
||
46 | | |___ | |_| | | | | |/ / | |__ |
||
47 | \___ \ | ___/ | | | |\ \ | __| |
||
48 | ___| | | | | | | | \ \ | |___ |
||
49 | /_____/ |_| |_| |_| \_\ |_____| |
||
50 | |||
51 | |||
52 | EOT; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | const NAME = 'Spike Client'; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $id; |
||
63 | |||
64 | /** |
||
65 | * @var Configuration |
||
66 | */ |
||
67 | protected $configuration; |
||
68 | |||
69 | /** |
||
70 | * @var LoopInterface |
||
71 | */ |
||
72 | protected $eventLoop; |
||
73 | |||
74 | /** |
||
75 | * @var DispatcherInterface |
||
76 | */ |
||
77 | protected $eventDispatcher; |
||
78 | |||
79 | /** |
||
80 | * @var ConnectionInterface |
||
81 | */ |
||
82 | protected $controlConnection; |
||
83 | |||
84 | /** |
||
85 | * @var \DateTimeInterface |
||
86 | */ |
||
87 | protected $activeAt; |
||
88 | |||
89 | /** |
||
90 | * @var WorkerInterface[]|Collection |
||
91 | */ |
||
92 | protected $workers; |
||
93 | |||
94 | /** |
||
95 | * @var Logger |
||
96 | */ |
||
97 | protected $logger; |
||
98 | |||
99 | /** |
||
100 | * @var bool |
||
101 | */ |
||
102 | protected $running = false; |
||
103 | |||
104 | /** |
||
105 | * Whether connect to server. |
||
106 | * @var bool |
||
107 | */ |
||
108 | protected $connected = false; |
||
109 | |||
110 | public function __construct(Configuration $configuration, LoopInterface $eventLoop = null) |
||
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | public function getHelp() |
||
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | * |
||
131 | * @codeCoverageIgnore |
||
132 | */ |
||
133 | public function doRun(InputInterface $input, OutputInterface $output) |
||
152 | |||
153 | /** |
||
154 | * {@inheritdoc} |
||
155 | */ |
||
156 | public function start() |
||
174 | |||
175 | /** |
||
176 | * {@inheritdoc} |
||
177 | */ |
||
178 | public function close() |
||
192 | |||
193 | |||
194 | protected function reset() |
||
206 | |||
207 | /** |
||
208 | * Reconnect if disconnect from server. |
||
209 | */ |
||
210 | public function handleDisconnectServer() |
||
215 | |||
216 | /** |
||
217 | * Handles the control connection. |
||
218 | * |
||
219 | * @param ConnectionInterface $connection |
||
220 | * @codeCoverageIgnore |
||
221 | */ |
||
222 | protected function handleControlConnection(ConnectionInterface $connection) |
||
260 | |||
261 | /** |
||
262 | * Request for auth. |
||
263 | * |
||
264 | * @param ConnectionInterface $connection |
||
265 | * @codeCoverageIgnore |
||
266 | */ |
||
267 | protected function sendAuthRequest(ConnectionInterface $connection) |
||
276 | |||
277 | /** |
||
278 | * @return Configuration |
||
279 | */ |
||
280 | public function getConfiguration() |
||
284 | |||
285 | /** |
||
286 | * {@inheritdoc} |
||
287 | */ |
||
288 | public function getControlConnection() |
||
292 | |||
293 | /** |
||
294 | * {@inheritdoc} |
||
295 | */ |
||
296 | public function getId() |
||
300 | |||
301 | /** |
||
302 | * {@inheritdoc} |
||
303 | */ |
||
304 | public function setId($id) |
||
308 | |||
309 | /** |
||
310 | * {@inheritdoc} |
||
311 | */ |
||
312 | public function getActiveAt() |
||
316 | |||
317 | /** |
||
318 | * {@inheritdoc} |
||
319 | */ |
||
320 | public function getEventDispatcher() |
||
324 | |||
325 | /** |
||
326 | * @param \DateTimeInterface $activeAt |
||
327 | */ |
||
328 | public function setActiveAt($activeAt) |
||
332 | |||
333 | /** |
||
334 | * @return LoopInterface |
||
335 | */ |
||
336 | public function getEventLoop() |
||
340 | |||
341 | /** |
||
342 | * @return Collection|WorkerInterface[] |
||
343 | */ |
||
344 | public function getWorkers() |
||
348 | |||
349 | /** |
||
350 | * @return Logger |
||
351 | */ |
||
352 | public function getLogger() |
||
356 | |||
357 | /** |
||
358 | * {@inheritdoc} |
||
359 | */ |
||
360 | protected function getDefaultCommands() |
||
367 | |||
368 | protected function initializeEvents() |
||
373 | |||
374 | /** |
||
375 | * Creates default timers. |
||
376 | * |
||
377 | * @codeCoverageIgnore |
||
378 | */ |
||
379 | protected function initializeTimers() |
||
384 | } |
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: