mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
NetworkSession: remove circular dependency between queueCompressed() and flushSendBuffer()
this cycle makes the code fragile and prone to infinite looping bugs when modified, as well as making the code harder to follow.
This commit is contained in:
parent
46c57e4e24
commit
2e3940e8f5
@ -427,7 +427,7 @@ class NetworkSession{
|
||||
if(count($this->sendBuffer) > 0){
|
||||
$promise = $this->server->prepareBatch(PacketBatch::fromPackets(...$this->sendBuffer), $this->compressor, $immediate);
|
||||
$this->sendBuffer = [];
|
||||
$this->queueCompressed($promise, $immediate);
|
||||
$this->queueCompressedNoBufferFlush($promise, $immediate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -437,6 +437,10 @@ class NetworkSession{
|
||||
|
||||
public function queueCompressed(CompressBatchPromise $payload, bool $immediate = false) : void{
|
||||
$this->flushSendBuffer($immediate); //Maintain ordering if possible
|
||||
$this->queueCompressedNoBufferFlush($payload, $immediate);
|
||||
}
|
||||
|
||||
private function queueCompressedNoBufferFlush(CompressBatchPromise $payload, bool $immediate = false) : void{
|
||||
if($immediate){
|
||||
//Skips all queues
|
||||
$this->sendEncoded($payload->getResult(), true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user