From 9197c7013d5b98bdeb6b170b81ed80780939acf4 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 30 May 2019 15:39:51 +0200 Subject: [PATCH] Nice fix --- magna.php | 2 +- src/danog/MadelineProto/Loop/Update/FeedLoop.php | 16 ++++++++++------ .../MadelineProto/Loop/Update/UpdateLoop.php | 11 ++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/magna.php b/magna.php index ad206557..5469878e 100755 --- a/magna.php +++ b/magna.php @@ -293,7 +293,7 @@ if (!class_exists('\\danog\\MadelineProto\\VoIPServerConfig')) die('Install the '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(); if (!isset($MadelineProto->programmed_call)) { diff --git a/src/danog/MadelineProto/Loop/Update/FeedLoop.php b/src/danog/MadelineProto/Loop/Update/FeedLoop.php index 1dd72847..9d6dd3b1 100644 --- a/src/danog/MadelineProto/Loop/Update/FeedLoop.php +++ b/src/danog/MadelineProto/Loop/Update/FeedLoop.php @@ -44,7 +44,7 @@ class FeedLoop extends ResumableSignalLoop public function loop() { $API = $this->API; - $updater = $this->updater = $API->updaters[$this->channelId]; + $updater = ($this->updater = $API->updaters[$this->channelId]); if (!$this->API->settings['updates']['handle_updates']) { yield new Success(0); @@ -97,9 +97,13 @@ class FeedLoop extends ResumableSignalLoop } $this->parsedUpdates = []; if ($API->update_deferred) { - $API->logger->logger("Resuming deferred in $this", Logger::VERBOSE); - $API->update_deferred->resolve(); - $API->logger->logger("Done resuming deferred in $this", Logger::VERBOSE); + Loop::defer(function () use ($API) { + if ($API->update_deferred) { + $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)) { $this->API->loadChannelState($channelId, $update); 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])) { - $this->API->updaters[$channelId] = new UpdateLoop($this, $channelId); + $this->API->updaters[$channelId] = new UpdateLoop($this->API, $channelId); } $this->API->feeders[$channelId]->start(); $this->API->updaters[$channelId]->start(); diff --git a/src/danog/MadelineProto/Loop/Update/UpdateLoop.php b/src/danog/MadelineProto/Loop/Update/UpdateLoop.php index 481c6470..8bb01d53 100644 --- a/src/danog/MadelineProto/Loop/Update/UpdateLoop.php +++ b/src/danog/MadelineProto/Loop/Update/UpdateLoop.php @@ -20,6 +20,7 @@ namespace danog\MadelineProto\Loop\Update; use danog\MadelineProto\Logger; use danog\MadelineProto\Loop\Impl\ResumableSignalLoop; +use Amp\Loop; /** * Update loop. @@ -164,9 +165,13 @@ class UpdateLoop extends ResumableSignalLoop $this->API->feeders[$channelId]->resumeDefer(); } if ($API->update_deferred) { - $API->logger->logger("Resuming deferred in $this", Logger::VERBOSE); - $API->update_deferred->resolve(); - $API->logger->logger("Done resuming deferred in $this", Logger::VERBOSE); + Loop::defer(function () use ($API) { + if ($API->update_deferred) { + $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))) {