1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-10 17:28:18 +01:00
This commit is contained in:
Daniil Gentili 2024-12-10 17:55:48 +00:00
parent 6f9a616510
commit cfa546d7f7
4 changed files with 5 additions and 7 deletions

View File

@ -31,6 +31,7 @@ use danog\MadelineProto\Loop\Connection\CleanupLoop;
use danog\MadelineProto\Loop\Connection\HttpWaitLoop;
use danog\MadelineProto\Loop\Connection\ReadLoop;
use danog\MadelineProto\Loop\Connection\WriteLoop;
use danog\MadelineProto\MTProto\MTProtoIncomingMessage;
use danog\MadelineProto\MTProto\MTProtoOutgoingMessage;
use danog\MadelineProto\MTProtoSession\Session;
use danog\MadelineProto\Stream\BufferedStreamInterface;
@ -307,8 +308,9 @@ final class Connection
EventLoop::queue($lock->release(...));
}
}
public function wakeupHandler(): void
public function wakeupHandler(MTProtoIncomingMessage $message): void
{
$this->new_incoming->enqueue($message);
\assert($this->handler !== null);
Assert::true($this->handler->resume() || $this->handler->isRunning(), "Could not resume handler!");
}

View File

@ -120,7 +120,6 @@ final class ReadLoop extends Loop
return self::STOP;
}
$this->connection->httpReceived();
$this->connection->wakeupHandler();
return self::CONTINUE;
}
public function readMessage(): ?int
@ -251,8 +250,7 @@ final class ReadLoop extends Loop
$message->setSeqNo($seq_no);
}
$this->connection->new_incoming->enqueue($message);
$this->connection->incoming_messages[$message_id] = $message;
$this->connection->wakeupHandler($message);
$this->connection->incomingCtr?->inc();
} finally {
$this->connection->reading(false);

View File

@ -147,6 +147,7 @@ final class MTProtoIncomingMessage extends MTProtoMessage
*/
public function read(): array
{
$this->ack();
$this->state |= self::STATE_READ;
$content = $this->content;
$this->content = ['_' => $content['_']];

View File

@ -135,7 +135,6 @@ trait ResponseHandler
}
private function handleNewSession(MTProtoIncomingMessage $message): void
{
$message->ack();
$this->shared->getTempAuthKey()->setServerSalt($message->read()['server_salt']);
if ($this->API->authorized === \danog\MadelineProto\API::LOGGED_IN
&& isset($this->API->updaters[UpdateLoop::GENERIC])
@ -162,7 +161,6 @@ trait ResponseHandler
}
private function handleMsgCopy(MTProtoIncomingMessage $message): void
{
$message->ack();
$content = $message->read();
$referencedMsgId = $content['msg_id'];
if (isset($this->incoming_messages[$referencedMsgId])) {
@ -187,7 +185,6 @@ trait ResponseHandler
if ($message->unencrypted) {
throw new SecurityException("Can't accept unencrypted result!");
}
$message->ack();
$response = $response['result'];
}
if (!isset($this->outgoing_messages[$requestId])) {