mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 04:08:59 +01:00
Start IPC server immediately
This commit is contained in:
parent
7629e33f85
commit
0eb361cda5
2
docs
2
docs
@ -1 +1 @@
|
||||
Subproject commit 45b48bbb98e1d304e812b293327b4a951cf239e7
|
||||
Subproject commit 3b96f262cb4399f0b6bfe775840cacac24bdab3b
|
38
src/API.php
38
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user