diff --git a/CHANGELOG.md b/CHANGELOG.md index 5de7893a..f1a29983 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 87c04225..76bc6bad 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 7214ae6b..ba325015 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;