mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-10 13:28:16 +01:00
Lighten up
This commit is contained in:
parent
d79fca4bed
commit
96080c9467
@ -136,7 +136,6 @@ final class MTProtoIncomingMessage extends MTProtoMessage
|
||||
*/
|
||||
public function ack(): void
|
||||
{
|
||||
unset($this->connection->incoming_messages[$this->msgId]);
|
||||
$this->state |= self::STATE_ACKED;
|
||||
if ($this->contentRelated) {
|
||||
// I let the server know that I received its message
|
||||
@ -155,14 +154,6 @@ final class MTProtoIncomingMessage extends MTProtoMessage
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this message can be garbage collected.
|
||||
*/
|
||||
public function canGarbageCollect(): bool
|
||||
{
|
||||
return (bool) ($this->state & self::STATE_READ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ID of message to which this message replies.
|
||||
*/
|
||||
|
@ -128,9 +128,4 @@ abstract class MTProtoMessage
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this message can be garbage collected.
|
||||
*/
|
||||
abstract public function canGarbageCollect(): bool;
|
||||
}
|
||||
|
@ -36,11 +36,11 @@ trait Reliable
|
||||
*/
|
||||
public function onNewMsgDetailedInfo(array $content): void
|
||||
{
|
||||
if (isset($this->incoming_messages[$content['answer_msg_id']])) {
|
||||
/*if (isset($this->incoming_messages[$content['answer_msg_id']])) {
|
||||
$this->incoming_messages[$content['answer_msg_id']]->ack();
|
||||
} else {
|
||||
EventLoop::queue($this->objectCall(...), 'msg_resend_req', ['msg_ids' => [$content['answer_msg_id']]]);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
/**
|
||||
* Called when receiving a msg_detailed_info.
|
||||
@ -58,7 +58,7 @@ trait Reliable
|
||||
{
|
||||
$ok = true;
|
||||
foreach ($content['msg_ids'] as $msg_id) {
|
||||
if (!isset($this->outgoing_messages[$msg_id]) || isset($this->incoming_messages[$msg_id])) {
|
||||
if (!isset($this->outgoing_messages[$msg_id])) {
|
||||
$ok = false;
|
||||
}
|
||||
}
|
||||
@ -104,7 +104,7 @@ trait Reliable
|
||||
*/
|
||||
public function sendMsgsStateInfo(array $msg_ids, int $req_msg_id): void
|
||||
{
|
||||
$this->API->logger('Sending state info for '.\count($msg_ids).' message IDs');
|
||||
/*$this->API->logger('Sending state info for '.\count($msg_ids).' message IDs');
|
||||
$info = '';
|
||||
foreach ($msg_ids as $msg_id) {
|
||||
$cur_info = 0;
|
||||
@ -126,6 +126,6 @@ trait Reliable
|
||||
}
|
||||
$info .= \chr($cur_info);
|
||||
}
|
||||
EventLoop::queue($this->objectCall(...), 'msgs_state_info', ['req_msg_id' => $req_msg_id, 'info' => $info]);
|
||||
EventLoop::queue($this->objectCall(...), 'msgs_state_info', ['req_msg_id' => $req_msg_id, 'info' => $info]);*/
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ trait ResponseHandler
|
||||
$newMessage->setSeqNo(null);
|
||||
$tmp->enqueue($newMessage);
|
||||
$this->incomingCtr?->inc();
|
||||
$this->incoming_messages[$msg['msg_id']] = $newMessage;
|
||||
//$this->incoming_messages[$msg['msg_id']] = $newMessage;
|
||||
}
|
||||
$this->checkInSeqNo($message);
|
||||
$this->handleMessages($tmp);
|
||||
@ -163,15 +163,15 @@ trait ResponseHandler
|
||||
{
|
||||
$content = $message->read();
|
||||
$referencedMsgId = $content['msg_id'];
|
||||
if (isset($this->incoming_messages[$referencedMsgId])) {
|
||||
/*if (isset($this->incoming_messages[$referencedMsgId])) {
|
||||
$this->incoming_messages[$referencedMsgId]->ack();
|
||||
} else {
|
||||
} else {*/
|
||||
$this->msgIdHandler->checkIncomingMessageId($referencedMsgId, true);
|
||||
$message = new MTProtoIncomingMessage($this, $content['orig_message'], $referencedMsgId, $message->unencrypted);
|
||||
$this->incomingCtr?->inc();
|
||||
$this->incoming_messages[$referencedMsgId] = $message;
|
||||
//$this->incoming_messages[$referencedMsgId] = $message;
|
||||
$this->handleMessages([$message]);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ trait Session
|
||||
*
|
||||
* @var array<MTProtoIncomingMessage>
|
||||
*/
|
||||
public array $incoming_messages = [];
|
||||
//public array $incoming_messages = [];
|
||||
/**
|
||||
* Outgoing message array.
|
||||
*
|
||||
@ -155,24 +155,6 @@ trait Session
|
||||
*/
|
||||
public function cleanupSession(): void
|
||||
{
|
||||
$count = 0;
|
||||
$incoming = [];
|
||||
foreach ($this->incoming_messages as $key => $message) {
|
||||
if ($message->canGarbageCollect()) {
|
||||
$this->API->logger("Collecting incoming $message in DC {$this->datacenter}", Logger::VERBOSE);
|
||||
|
||||
$count++;
|
||||
} else {
|
||||
$this->API->logger("Can't garbage collect $message in DC {$this->datacenter}, not handled yet!", Logger::VERBOSE);
|
||||
$incoming[$key] = $message;
|
||||
}
|
||||
}
|
||||
$this->incoming_messages = $incoming;
|
||||
$total = \count($this->incoming_messages);
|
||||
if ($count+$total) {
|
||||
$this->API->logger("Garbage collected $count incoming messages in DC {$this->datacenter}, $total left", Logger::VERBOSE);
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$outgoing = [];
|
||||
foreach ($this->outgoing_messages as $key => $message) {
|
||||
|
Loading…
Reference in New Issue
Block a user