Various improvements
This commit is contained in:
parent
b22a193014
commit
1d16cf807b
@ -258,7 +258,7 @@ class API extends InternalDoc
|
||||
}
|
||||
$this->API->unreference();
|
||||
}
|
||||
if (isset($this->wrapper) && !Magic::$signaled) {
|
||||
if (isset($this->wrapper) && (!Magic::$signaled || $this->gettingApiId)) {
|
||||
$this->logger->logger('Prompting final serialization...');
|
||||
Tools::wait($this->wrapper->serialize());
|
||||
$this->logger->logger('Done final serialization!');
|
||||
|
@ -24,6 +24,10 @@ namespace danog\MadelineProto;
|
||||
*/
|
||||
abstract class EventHandler extends InternalDoc
|
||||
{
|
||||
/**
|
||||
* Whether the event handler was started.
|
||||
*/
|
||||
private bool $startedInternal = false;
|
||||
/**
|
||||
* Internal constructor.
|
||||
*
|
||||
@ -41,6 +45,23 @@ abstract class EventHandler extends InternalDoc
|
||||
$this->{$namespace} = $this->exportNamespace($namespace);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Start method handler.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
public function startInternal(): \Generator
|
||||
{
|
||||
if ($this->startedInternal) {
|
||||
return;
|
||||
}
|
||||
if (\method_exists($this, 'onStart')) {
|
||||
yield $this->onStart();
|
||||
}
|
||||
$this->startedInternal = true;
|
||||
}
|
||||
/**
|
||||
* Get peers where to send error reports.
|
||||
*
|
||||
|
@ -79,6 +79,7 @@ trait Events
|
||||
}
|
||||
$this->initEventHandler($eventHandler);
|
||||
$this->eventHandlerMethods = [];
|
||||
$this->loop_callback = null;
|
||||
foreach (\get_class_methods($this->event_handler) as $method) {
|
||||
if ($method === 'onLoop') {
|
||||
$this->loop_callback = [$this->event_handler_instance, 'onLoop'];
|
||||
@ -96,9 +97,7 @@ trait Events
|
||||
}
|
||||
}
|
||||
yield from $this->setReportPeers($this->event_handler_instance->getReportPeers());
|
||||
if (\method_exists($this->event_handler_instance, 'onStart')) {
|
||||
Tools::callFork($this->event_handler_instance->onStart());
|
||||
}
|
||||
Tools::callFork($this->event_handler_instance->startInternal());
|
||||
$this->updateHandler = [$this, 'eventUpdateHandler'];
|
||||
if ($this->inited()) {
|
||||
$this->startUpdateSystem();
|
||||
|
Loading…
x
Reference in New Issue
Block a user