NetworkSession: fixed some segments of recv/send logic not being covered by their respective network timingsÂ

This commit is contained in:
Dylan K. Taylor 2023-02-19 17:21:10 +00:00
parent d5e92b4ae6
commit 4dbcd714bd
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -376,6 +376,8 @@ class NetworkSession{
return; return;
} }
Timings::$playerNetworkReceive->startTiming();
try{
if($this->incomingPacketBatchBudget <= 0){ if($this->incomingPacketBatchBudget <= 0){
$this->updatePacketBudget(); $this->updatePacketBudget();
if($this->incomingPacketBatchBudget <= 0){ if($this->incomingPacketBatchBudget <= 0){
@ -433,6 +435,9 @@ class NetworkSession{
$this->logger->logException($e); $this->logger->logException($e);
throw PacketHandlingException::wrap($e, "Packet batch decode error"); throw PacketHandlingException::wrap($e, "Packet batch decode error");
} }
}finally{
Timings::$playerNetworkReceive->stopTiming();
}
} }
/** /**
@ -519,6 +524,8 @@ class NetworkSession{
private function flushSendBuffer(bool $immediate = false) : void{ private function flushSendBuffer(bool $immediate = false) : void{
if(count($this->sendBuffer) > 0){ if(count($this->sendBuffer) > 0){
Timings::$playerNetworkSend->startTiming();
try{
$syncMode = null; //automatic $syncMode = null; //automatic
if($immediate){ if($immediate){
$syncMode = true; $syncMode = true;
@ -537,6 +544,9 @@ class NetworkSession{
} }
$this->sendBuffer = []; $this->sendBuffer = [];
$this->queueCompressedNoBufferFlush($promise, $immediate); $this->queueCompressedNoBufferFlush($promise, $immediate);
}finally{
Timings::$playerNetworkSend->stopTiming();
}
} }
} }
@ -549,11 +559,18 @@ class NetworkSession{
} }
public function queueCompressed(CompressBatchPromise $payload, bool $immediate = false) : void{ public function queueCompressed(CompressBatchPromise $payload, bool $immediate = false) : void{
Timings::$playerNetworkSend->startTiming();
try{
$this->flushSendBuffer($immediate); //Maintain ordering if possible $this->flushSendBuffer($immediate); //Maintain ordering if possible
$this->queueCompressedNoBufferFlush($payload, $immediate); $this->queueCompressedNoBufferFlush($payload, $immediate);
}finally{
Timings::$playerNetworkSend->stopTiming();
}
} }
private function queueCompressedNoBufferFlush(CompressBatchPromise $payload, bool $immediate = false) : void{ private function queueCompressedNoBufferFlush(CompressBatchPromise $payload, bool $immediate = false) : void{
Timings::$playerNetworkSend->startTiming();
try{
if($immediate){ if($immediate){
//Skips all queues //Skips all queues
$this->sendEncoded($payload->getResult(), true); $this->sendEncoded($payload->getResult(), true);
@ -579,6 +596,9 @@ class NetworkSession{
} }
}); });
} }
}finally{
Timings::$playerNetworkSend->stopTiming();
}
} }
private function sendEncoded(string $payload, bool $immediate = false) : void{ private function sendEncoded(string $payload, bool $immediate = false) : void{