diff --git a/src/MTProto/MTProtoIncomingMessage.php b/src/MTProto/MTProtoIncomingMessage.php index 558e99d6f..b4bc9f25a 100644 --- a/src/MTProto/MTProtoIncomingMessage.php +++ b/src/MTProto/MTProtoIncomingMessage.php @@ -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. */ diff --git a/src/MTProto/MTProtoMessage.php b/src/MTProto/MTProtoMessage.php index bd9c3f12e..31a54799b 100644 --- a/src/MTProto/MTProtoMessage.php +++ b/src/MTProto/MTProtoMessage.php @@ -128,9 +128,4 @@ abstract class MTProtoMessage return $this; } - - /** - * Check whether this message can be garbage collected. - */ - abstract public function canGarbageCollect(): bool; } diff --git a/src/MTProtoSession/Reliable.php b/src/MTProtoSession/Reliable.php index 3536d66a8..0f2c451ff 100644 --- a/src/MTProtoSession/Reliable.php +++ b/src/MTProtoSession/Reliable.php @@ -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]);*/ } } diff --git a/src/MTProtoSession/ResponseHandler.php b/src/MTProtoSession/ResponseHandler.php index dba3762fa..6fb0a19e4 100644 --- a/src/MTProtoSession/ResponseHandler.php +++ b/src/MTProtoSession/ResponseHandler.php @@ -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]); - } + //} } /** diff --git a/src/MTProtoSession/Session.php b/src/MTProtoSession/Session.php index 473c74563..24753ff40 100644 --- a/src/MTProtoSession/Session.php +++ b/src/MTProtoSession/Session.php @@ -57,7 +57,7 @@ trait Session * * @var array */ - 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) {