diff --git a/CHANGELOG.md b/CHANGELOG.md index b1c2d02a..bcc0306e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,19 @@ ## 4.0.0 Full async -Full async +**Fully asynchronous MadelineProto, thanks to [amphp](https://github.com/danog/amphp)!** -Improved message splitting algorithm: performance improvements, and it will now notify you via the logs if there are too many entities in the logs, or if the entities are too long. -Improved get_self method. +* Fully rewritten connection stack, with support for websockets, stuff +* updates +* Improved message splitting algorithm: performance improvements, and it will now notify you via the logs if there are too many entities in the logs, or if the entities are too long. +* Improved get_self method. +* Rewritten proxy stack + + +Things to expect in the next releases: +Document async apis +optional max_id and min_id +async iterators +Method name changes +#MadelineProtoForNode async +lua async \ No newline at end of file diff --git a/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php b/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php index 090b7406..f943a213 100644 --- a/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php @@ -64,6 +64,7 @@ trait ResponseHandler while ($this->datacenter->sockets[$datacenter]->new_incoming) { reset($this->datacenter->sockets[$datacenter]->new_incoming); $current_msg_id = key($this->datacenter->sockets[$datacenter]->new_incoming); + if (!isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id])) continue; $this->logger->logger((isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['from_container']) ? 'Inside of container, received ' : 'Received ').$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].' from DC '.$datacenter, \danog\MadelineProto\Logger::ULTRA_VERBOSE); switch ($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_']) { diff --git a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php index eff4fdaf..4ee42c23 100644 --- a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php @@ -22,9 +22,6 @@ namespace danog\MadelineProto\MTProtoTools; use Amp\Artax\Request; use Amp\Deferred; use Amp\Delayed; -use function Amp\Promise\any; -use danog\MadelineProto\Loop\Update\FeedLoop; -use danog\MadelineProto\Loop\Update\UpdateLoop; use Amp\Loop; /** @@ -81,7 +78,7 @@ trait UpdateHandler if (!$params['timeout']) { $params['timeout'] = 0.001; } - yield any([$this->waitUpdate(), new Delayed($params['timeout'] * 1000)]); + yield $this->any([$this->waitUpdate(), new Delayed($params['timeout'] * 1000)]); } if (empty($this->updates)) { diff --git a/src/danog/MadelineProto/Tools.php b/src/danog/MadelineProto/Tools.php index 33838a41..2ceef8c5 100644 --- a/src/danog/MadelineProto/Tools.php +++ b/src/danog/MadelineProto/Tools.php @@ -24,6 +24,7 @@ use Amp\Loop; use Amp\Promise; use Amp\Success; use function Amp\Promise\all; +use function Amp\Promise\any; use function Amp\Promise\wait; /** @@ -230,6 +231,13 @@ trait Tools } return all($promises); } + public function any($promises) + { + foreach ($promises as &$promise) { + $promise = $this->call($promise); + } + return any($promises); + } public function call($promise) { if ($promise instanceof \Generator) {