diff --git a/docs b/docs index 45b48bbb9..3b96f262c 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 45b48bbb98e1d304e812b293327b4a951cf239e7 +Subproject commit 3b96f262cb4399f0b6bfe775840cacac24bdab3b diff --git a/src/API.php b/src/API.php index f856545ae..c15508f5a 100644 --- a/src/API.php +++ b/src/API.php @@ -51,7 +51,7 @@ final class API extends AbstractAPI * * @var string */ - public const RELEASE = '8.2.3'; + public const RELEASE = '8.2.4'; /** * We're not logged in. * @@ -220,6 +220,11 @@ final class API extends AbstractAPI $this->wrapper->logger('Prompting initial serialization...'); $this->wrapper->serialize(); $this->wrapper->logger('Done initial serialization!'); + $this->destruct(); + if (!$this->connectToMadelineProto($settings)) { + throw new Exception("Could not start IPC server!"); + } + $this->wrapper->logger(Lang::$current_lang['madelineproto_ready'], Logger::NOTICE); } @@ -366,6 +371,23 @@ final class API extends AbstractAPI await(self::$destructors); } } + + private function destruct(int|null $id = null): void + { + $this->wrapper->logger('Shutting down MadelineProto ('.static::class.')'); + $this->wrapper->getAPI()?->unreference(); + if (isset($this->wrapper)) { + $this->wrapper->logger('Prompting final serialization...'); + $this->wrapper->serialize(); + $this->wrapper->logger('Done final serialization!'); + } + if ($this->unlock) { + ($this->unlock)(); + } + if ($id !== null) { + unset(self::$destructors[$id]); + } + } /** * Destruct function. * @@ -374,19 +396,7 @@ final class API extends AbstractAPI public function __destruct() { $id = \count(self::$destructors); - self::$destructors[$id] = async(function () use ($id): void { - $this->wrapper->logger('Shutting down MadelineProto ('.static::class.')'); - $this->wrapper->getAPI()?->unreference(); - if (isset($this->wrapper)) { - $this->wrapper->logger('Prompting final serialization...'); - $this->wrapper->serialize(); - $this->wrapper->logger('Done final serialization!'); - } - if ($this->unlock) { - ($this->unlock)(); - } - unset(self::$destructors[$id]); - }); + self::$destructors[$id] = async($this->destruct(...), $id); } /**