1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-26 17:44:44 +01:00

Start IPC server immediately

This commit is contained in:
Daniil Gentili 2024-08-23 10:54:57 +02:00
parent 7629e33f85
commit 0eb361cda5
2 changed files with 25 additions and 15 deletions

2
docs

@ -1 +1 @@
Subproject commit 45b48bbb98e1d304e812b293327b4a951cf239e7
Subproject commit 3b96f262cb4399f0b6bfe775840cacac24bdab3b

View File

@ -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);
}
/**