This commit is contained in:
Daniil Gentili 2019-05-30 15:39:51 +02:00
parent be11dcfef1
commit 9197c7013d
3 changed files with 19 additions and 10 deletions

View File

@ -293,7 +293,7 @@ if (!class_exists('\\danog\\MadelineProto\\VoIPServerConfig')) die('Install the
'audio_congestion_window' => 4 * 1024, 'audio_congestion_window' => 4 * 1024,
] ]
); );
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['secret_chats' => ['accept_chats' => false], 'logger' => ['logger' => 3, 'logger_param' => getcwd() . '/MadelineProto.log']]); $MadelineProto = new \danog\MadelineProto\API('session.madeline', ['secret_chats' => ['accept_chats' => false], 'logger' => ['logger' => 3, 'logger_level' => 5, 'logger_param' => getcwd() . '/MadelineProto.log']]);
$MadelineProto->start(); $MadelineProto->start();
if (!isset($MadelineProto->programmed_call)) { if (!isset($MadelineProto->programmed_call)) {

View File

@ -44,7 +44,7 @@ class FeedLoop extends ResumableSignalLoop
public function loop() public function loop()
{ {
$API = $this->API; $API = $this->API;
$updater = $this->updater = $API->updaters[$this->channelId]; $updater = ($this->updater = $API->updaters[$this->channelId]);
if (!$this->API->settings['updates']['handle_updates']) { if (!$this->API->settings['updates']['handle_updates']) {
yield new Success(0); yield new Success(0);
@ -97,9 +97,13 @@ class FeedLoop extends ResumableSignalLoop
} }
$this->parsedUpdates = []; $this->parsedUpdates = [];
if ($API->update_deferred) { if ($API->update_deferred) {
$API->logger->logger("Resuming deferred in $this", Logger::VERBOSE); Loop::defer(function () use ($API) {
$API->update_deferred->resolve(); if ($API->update_deferred) {
$API->logger->logger("Done resuming deferred in $this", Logger::VERBOSE); $API->logger->logger("Resuming deferred in $this", Logger::VERBOSE);
$API->update_deferred->resolve();
$API->logger->logger("Done resuming deferred in $this", Logger::VERBOSE);
}
});
} }
} }
@ -193,10 +197,10 @@ class FeedLoop extends ResumableSignalLoop
if ($channelId && !$this->API->getChannelStates()->has($channelId)) { if ($channelId && !$this->API->getChannelStates()->has($channelId)) {
$this->API->loadChannelState($channelId, $update); $this->API->loadChannelState($channelId, $update);
if (!isset($this->API->feeders[$channelId])) { if (!isset($this->API->feeders[$channelId])) {
$this->API->feeders[$channelId] = new FeedLoop($this, $channelId); $this->API->feeders[$channelId] = new FeedLoop($this->API, $channelId);
} }
if (!isset($this->API->updaters[$channelId])) { if (!isset($this->API->updaters[$channelId])) {
$this->API->updaters[$channelId] = new UpdateLoop($this, $channelId); $this->API->updaters[$channelId] = new UpdateLoop($this->API, $channelId);
} }
$this->API->feeders[$channelId]->start(); $this->API->feeders[$channelId]->start();
$this->API->updaters[$channelId]->start(); $this->API->updaters[$channelId]->start();

View File

@ -20,6 +20,7 @@ namespace danog\MadelineProto\Loop\Update;
use danog\MadelineProto\Logger; use danog\MadelineProto\Logger;
use danog\MadelineProto\Loop\Impl\ResumableSignalLoop; use danog\MadelineProto\Loop\Impl\ResumableSignalLoop;
use Amp\Loop;
/** /**
* Update loop. * Update loop.
@ -164,9 +165,13 @@ class UpdateLoop extends ResumableSignalLoop
$this->API->feeders[$channelId]->resumeDefer(); $this->API->feeders[$channelId]->resumeDefer();
} }
if ($API->update_deferred) { if ($API->update_deferred) {
$API->logger->logger("Resuming deferred in $this", Logger::VERBOSE); Loop::defer(function () use ($API) {
$API->update_deferred->resolve(); if ($API->update_deferred) {
$API->logger->logger("Done resuming deferred in $this", Logger::VERBOSE); $API->logger->logger("Resuming deferred in $this", Logger::VERBOSE);
$API->update_deferred->resolve();
$API->logger->logger("Done resuming deferred in $this", Logger::VERBOSE);
}
});
} }
if (yield $this->waitSignal($this->pause($timeout))) { if (yield $this->waitSignal($this->pause($timeout))) {