1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 06:59:01 +01:00
This commit is contained in:
Daniil Gentili 2019-06-01 12:47:18 +02:00
parent e38ecb9010
commit 2118665a29
4 changed files with 25 additions and 7 deletions

View File

@ -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

View File

@ -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']['_']) {

View File

@ -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)) {

View File

@ -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) {