mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 21:35:21 +00:00
ÂNetworkSession: ensure onResolve handler for CompressBatchPromise is covered by network send timings
This commit is contained in:
parent
765aef0810
commit
9a969e21c7
@ -561,20 +561,25 @@ class NetworkSession{
|
|||||||
$this->compressedQueue->enqueue($payload);
|
$this->compressedQueue->enqueue($payload);
|
||||||
$payload->onResolve(function(CompressBatchPromise $payload) : void{
|
$payload->onResolve(function(CompressBatchPromise $payload) : void{
|
||||||
if($this->connected && $this->compressedQueue->bottom() === $payload){
|
if($this->connected && $this->compressedQueue->bottom() === $payload){
|
||||||
$this->compressedQueue->dequeue(); //result unused
|
Timings::$playerNetworkSend->startTiming();
|
||||||
$this->sendEncoded($payload->getResult());
|
try{
|
||||||
|
$this->compressedQueue->dequeue(); //result unused
|
||||||
|
$this->sendEncoded($payload->getResult());
|
||||||
|
|
||||||
while(!$this->compressedQueue->isEmpty()){
|
while(!$this->compressedQueue->isEmpty()){
|
||||||
/** @var CompressBatchPromise $current */
|
/** @var CompressBatchPromise $current */
|
||||||
$current = $this->compressedQueue->bottom();
|
$current = $this->compressedQueue->bottom();
|
||||||
if($current->hasResult()){
|
if($current->hasResult()){
|
||||||
$this->compressedQueue->dequeue();
|
$this->compressedQueue->dequeue();
|
||||||
|
|
||||||
$this->sendEncoded($current->getResult());
|
$this->sendEncoded($current->getResult());
|
||||||
}else{
|
}else{
|
||||||
//can't send any more queued until this one is ready
|
//can't send any more queued until this one is ready
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}finally{
|
||||||
|
Timings::$playerNetworkSend->stopTiming();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user