eventTimer[$timerId]); try { $func(...$args); } catch (Throwable $e) { $this->error($e); } }); $this->eventTimer[$timerId] = $timerId; return $timerId; } /** * {@inheritdoc} */ public function offDelay(int $timerId): bool { if (isset($this->eventTimer[$timerId])) { $res = Timer::clear($timerId); unset($this->eventTimer[$timerId]); return $res; } return false; } /** * {@inheritdoc} */ public function offRepeat(int $timerId): bool { return $this->offDelay($timerId); } /** * {@inheritdoc} * @throws Throwable */ public function repeat(float $interval, callable $func, array $args = []): int { $t = (int)($interval * 1000); $t = max($t, 1); $timerId = Timer::tick($t, function () use ($func, $args) { try { $func(...$args); } catch (Throwable $e) { $this->error($e); } }); $this->eventTimer[$timerId] = $timerId; return $timerId; } /** * {@inheritdoc} */ public function onReadable($stream, callable $func): void { $fd = (int)$stream; if (!isset($this->readEvents[$fd]) && !isset($this->writeEvents[$fd])) { Event::add($stream, $func, null, SWOOLE_EVENT_READ); } else { if (isset($this->writeEvents[$fd])) { Event::set($stream, $func, null, SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE); } else { Event::set($stream, $func, null, SWOOLE_EVENT_READ); } } $this->readEvents[$fd] = $stream; } /** * {@inheritdoc} */ public function offReadable($stream): bool { $fd = (int)$stream; if (!isset($this->readEvents[$fd])) { return false; } unset($this->readEvents[$fd]); if (!isset($this->writeEvents[$fd])) { Event::del($stream); return true; } Event::set($stream, null, null, SWOOLE_EVENT_WRITE); return true; } /** * {@inheritdoc} */ public function onWritable($stream, callable $func): void { $fd = (int)$stream; if (!isset($this->readEvents[$fd]) && !isset($this->writeEvents[$fd])) { Event::add($stream, null, $func, SWOOLE_EVENT_WRITE); } else { if (isset($this->readEvents[$fd])) { Event::set($stream, null, $func, SWOOLE_EVENT_WRITE | SWOOLE_EVENT_READ); } else { Event::set($stream, null, $func, SWOOLE_EVENT_WRITE); } } $this->writeEvents[$fd] = $stream; } /** * {@inheritdoc} */ public function offWritable($stream): bool { $fd = (int)$stream; if (!isset($this->writeEvents[$fd])) { return false; } unset($this->writeEvents[$fd]); if (!isset($this->readEvents[$fd])) { Event::del($stream); return true; } Event::set($stream, null, null, SWOOLE_EVENT_READ); return true; } /** * {@inheritdoc} */ public function onSignal(int $signal, callable $func): void { Process::signal($signal, $func); } /** * {@inheritdoc} */ public function offSignal(int $signal): bool { return Process::signal($signal, function () { }); } /** * {@inheritdoc} */ public function deleteAllTimer(): void { foreach ($this->eventTimer as $timerId) { Timer::clear($timerId); } } /** * {@inheritdoc} */ public function run(): void { Event::wait(); } /** * Destroy loop. * * @return void */ public function stop(): void { Event::exit(); posix_kill(posix_getpid(), SIGINT); } /** * Get timer count. * * @return integer */ public function getTimerCount(): int { return count($this->eventTimer); } /** * {@inheritdoc} */ public function setErrorHandler(callable $errorHandler): void { $this->errorHandler = $errorHandler; } /** * {@inheritdoc} */ public function getErrorHandler(): ?callable { return $this->errorHandler; } /** * @param Throwable $e * @return void * @throws Throwable */ public function error(Throwable $e): void { if (!$this->errorHandler) { throw new $e; } ($this->errorHandler)($e); } } __halt_compiler();----SIGNATURE:----gQlYEOnk/sYw5nxTz/5I5MyluzSSycyqD943N04rOiaAoy3H2GvNdYSBCGzNQ2xUlxrlYXYJgkzg9JbWxF8xOKG4xTZp+1lhQqYRU+7rjIbUME4Knui+ughMiPfNz/iMYT0NmgNRnoDUKGoZ8iqfUuP6MAJgzUx0MCtP72BC7bWxFpdBdJIdFC+F1X12o8byvzSF7XszYlPdp5OERSzoKxaa7BePHynokUwZTme4RkbR3H6v649tbYq27qHzqVWrM/qliqDT3d7m59u92U6sgKcOMHvQ8IHs3SKr4+lLug31QbP1DTBhVrtHbBbVsvlW1i+B1Q7p1ln8jBwC4FLmyJ1vKDD3KbGKu5md10+QKuzWIH1S9C5HldJChdWWqvCSdYXcGO9szPwY2zoEDlpdM0xtM7yuh8OBQMJdpGpopukGiSU41R9JgToul71trk20Itd6hmwd9kdnoOmnt2Cm/I9Y4etP+2y+pTzOTePna3ssDhw4/2L3qH5BI7NPh6yElgPWhxP3M9BiZ0/kQlvi6Gxk9XCKZi5B3rC/KCOu3w7c5wZmiwrAlVf4iFKZAeyktkYldMvpcU77FM7Hopu2Q9krbeCTDycPWWo1dYZGZwU8eyLCFfBBxEqLhBh5tGW3WL360Bk2zqgLGLcqxPI9D5G/fbdJcE7F4EyBL+HFeJo=----ATTACHMENT:----MjU1NzQ5NTYzODYxODMzMiAzMTY3MDY4Mjg5MzgwMTUyIDI0MzcwODY1NjQ4MDYwMzY=