From 33041140e234a50c6dd792a612e0b5d5c9b0b5bb Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 2 Jun 2019 13:45:12 +0200 Subject: [PATCH] Add continue constant to genericloop --- CHANGELOG.md | 1 + src/danog/MadelineProto/Loop/Generic/GenericLoop.php | 11 +++++++++-- src/danog/MadelineProto/Loop/Impl/Loop.php | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5de7893a8..f1a299834 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ * split acks * TL callabck * channel state +* logger Things to expect in the next releases: Document async apis optional max_id and min_id diff --git a/src/danog/MadelineProto/Loop/Generic/GenericLoop.php b/src/danog/MadelineProto/Loop/Generic/GenericLoop.php index 87c042252..76bc6bad2 100644 --- a/src/danog/MadelineProto/Loop/Generic/GenericLoop.php +++ b/src/danog/MadelineProto/Loop/Generic/GenericLoop.php @@ -29,6 +29,7 @@ class GenericLoop extends ResumableSignalLoop { const STOP = -1; const PAUSE = null; + const CONTINUE = 0; protected $callback; protected $name; @@ -36,9 +37,15 @@ class GenericLoop extends ResumableSignalLoop /** * Constructor * + * The callback will be bound to the GenericLoop instance: this means that you will be able to use `$this` as if the callback were actually the `loop` function (you can access the API property, use the pause/waitSignal methods & so on). + * The return value of the callable can be: + * A number - the loop will be paused for the specified number of seconds + * GenericLoop::STOP - The loop will stop + * GenericLoop::PAUSE - The loop will pause forever (or until the `resume` method is called on the loop object from outside the loop) + * GenericLoop::CONTINUE - Return this if you want to rerun the loop without waiting + * * @param \danog\MadelineProto\API $API Instance of MadelineProto - * @param callback $callback Callback to run periodically - * @param int $timeout Timeout + * @param callback $callback Callback to run * @param string $name Fetcher name */ public function __construct($API, $callback, $name) diff --git a/src/danog/MadelineProto/Loop/Impl/Loop.php b/src/danog/MadelineProto/Loop/Impl/Loop.php index 7214ae6b0..ba3250156 100644 --- a/src/danog/MadelineProto/Loop/Impl/Loop.php +++ b/src/danog/MadelineProto/Loop/Impl/Loop.php @@ -35,7 +35,7 @@ abstract class Loop implements LoopInterface private $count = 0; - protected $API; + public $API; public function __construct($API) { $this->API = $API;