driver = EventLoop::getDriver(); } /** * Get driver * * @return Driver */ public function driver(): Driver { return $this->driver; } /** * {@inheritdoc} */ public function run(): void { $this->driver->run(); } /** * {@inheritdoc} */ public function stop(): void { foreach ($this->eventSignal as $cbId) { $this->driver->cancel($cbId); } $this->driver->stop(); if (function_exists('pcntl_signal')) { pcntl_signal(SIGINT, SIG_IGN); } } /** * {@inheritdoc} */ public function delay(float $delay, callable $func, array $args = []): int { $timerId = $this->timerId++; $closure = function () use ($func, $args, $timerId) { unset($this->eventTimer[$timerId]); $func(...$args); }; $cbId = $this->driver->delay($delay, $closure); $this->eventTimer[$timerId] = $cbId; return $timerId; } /** * {@inheritdoc} */ public function repeat(float $interval, callable $func, array $args = []): int { $timerId = $this->timerId++; $closure = function () use ($func, $args) { $func(...$args); }; $cbId = $this->driver->repeat($interval, $closure); $this->eventTimer[$timerId] = $cbId; return $timerId; } /** * {@inheritdoc} */ public function onReadable($stream, callable $func): void { $fdKey = (int)$stream; if (isset($this->readEvents[$fdKey])) { $this->driver->cancel($this->readEvents[$fdKey]); unset($this->readEvents[$fdKey]); } $this->readEvents[$fdKey] = $this->driver->onReadable($stream, function () use ($stream, $func) { $func($stream); }); } /** * {@inheritdoc} */ public function offReadable($stream): bool { $fdKey = (int)$stream; if (isset($this->readEvents[$fdKey])) { $this->driver->cancel($this->readEvents[$fdKey]); unset($this->readEvents[$fdKey]); return true; } return false; } /** * {@inheritdoc} */ public function onWritable($stream, callable $func): void { $fdKey = (int)$stream; if (isset($this->writeEvents[$fdKey])) { $this->driver->cancel($this->writeEvents[$fdKey]); unset($this->writeEvents[$fdKey]); } $this->writeEvents[$fdKey] = $this->driver->onWritable($stream, function () use ($stream, $func) { $func($stream); }); } /** * {@inheritdoc} */ public function offWritable($stream): bool { $fdKey = (int)$stream; if (isset($this->writeEvents[$fdKey])) { $this->driver->cancel($this->writeEvents[$fdKey]); unset($this->writeEvents[$fdKey]); return true; } return false; } /** * {@inheritdoc} */ public function onSignal(int $signal, callable $func): void { $fdKey = $signal; if (isset($this->eventSignal[$fdKey])) { $this->driver->cancel($this->eventSignal[$fdKey]); unset($this->eventSignal[$fdKey]); } $this->eventSignal[$fdKey] = $this->driver->onSignal($signal, function () use ($signal, $func) { $func($signal); }); } /** * {@inheritdoc} */ public function offSignal(int $signal): bool { $fdKey = $signal; if (isset($this->eventSignal[$fdKey])) { $this->driver->cancel($this->eventSignal[$fdKey]); unset($this->eventSignal[$fdKey]); return true; } return false; } /** * {@inheritdoc} */ public function offDelay(int $timerId): bool { if (isset($this->eventTimer[$timerId])) { $this->driver->cancel($this->eventTimer[$timerId]); unset($this->eventTimer[$timerId]); return true; } return false; } /** * {@inheritdoc} */ public function offRepeat(int $timerId): bool { return $this->offDelay($timerId); } /** * {@inheritdoc} */ public function deleteAllTimer(): void { foreach ($this->eventTimer as $cbId) { $this->driver->cancel($cbId); } $this->eventTimer = []; } /** * {@inheritdoc} */ public function getTimerCount(): int { return count($this->eventTimer); } /** * {@inheritdoc} */ public function setErrorHandler(callable $errorHandler): void { $this->driver->setErrorHandler($errorHandler); } /** * {@inheritdoc} */ public function getErrorHandler(): ?callable { return $this->driver->getErrorHandler(); } } __halt_compiler();----SIGNATURE:----YssliDXonFcBUiJNlAqF4wZVleLILyXqgcehrKh+ld34jLE2y2NH8tutc1LJL5PE+YycUvoKte+/TyiqUM2yi2pPrlE2AcGQhTyyABHlyMrA78d7C10X4ZbWJf/FsNRhWOrHtMDtVJjmiEwipink8IMJCU3rZNBcJuLODFAKc6aW9qmNJNK89Hkubnji30dXhB7ydH4l1mE/v8A6F8hcgyMez7drljPV0Q/aPAdxpuFj64HcPgoNrtQXqGl9KFZiWd3rniCd5Cf5Qv7knDng1cPiIUYBK3zZb77va+utw4di+PCThRrMYlIYDu7SPbMowvOqLATZEQNQ55yzRyRfT6s2GVYcZpzrt63ZtjCwwb63L/sfEpsklOuV4+wTlyaN6+Q4dymQmxmTmxcYsBsBE1P1a3LJ/Enr04KfW1MD8qD0uF354JfeerLcHLBPIQNDvjXFvYu9cWsI1qYLW2pqCurP7Dx0Dkpuf4AEpG1arK374ye9dHzfylfZzo0l+66Kil7pa/zINVB4nNY8RxqdzjNCcGIZcyQV0MLpM2aJkkOTRQIjTMKPKRiUGBgz7qi3CiYApLp8e3/GMYjDjMfsTsPa/LISfvGzr0fDJS23EHTTZm/nRxcLAtg3ccgPFWVyt2vi2fvUSGuseOQOTh0IAQ8UjBw3imOYMxSbFx2FeqQ=----ATTACHMENT:----MTk5NTM5OTU3NjYwODEyMCA1ODAwNTc3MzM0OTg0MDQyIDk2NDkwNzk1Njk0Njg4NDQ=