mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Timings: fixed receivePacket timer showing 2x the actual number of received packets
This commit is contained in:
parent
328b87fc18
commit
b13e97de3d
@ -431,32 +431,39 @@ class NetworkSession{
|
|||||||
throw new PacketHandlingException("Unexpected non-serverbound packet");
|
throw new PacketHandlingException("Unexpected non-serverbound packet");
|
||||||
}
|
}
|
||||||
|
|
||||||
$timings = Timings::getDecodeDataPacketTimings($packet);
|
$timings = Timings::getReceiveDataPacketTimings($packet);
|
||||||
$timings->startTiming();
|
$timings->startTiming();
|
||||||
try{
|
|
||||||
$stream = PacketSerializer::decoder($buffer, 0, $this->packetSerializerContext);
|
|
||||||
try{
|
|
||||||
$packet->decode($stream);
|
|
||||||
}catch(PacketDecodeException $e){
|
|
||||||
throw PacketHandlingException::wrap($e);
|
|
||||||
}
|
|
||||||
if(!$stream->feof()){
|
|
||||||
$remains = substr($stream->getBuffer(), $stream->getOffset());
|
|
||||||
$this->logger->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": " . bin2hex($remains));
|
|
||||||
}
|
|
||||||
}finally{
|
|
||||||
$timings->stopTiming();
|
|
||||||
}
|
|
||||||
|
|
||||||
$timings = Timings::getHandleDataPacketTimings($packet);
|
|
||||||
$timings->startTiming();
|
|
||||||
try{
|
try{
|
||||||
//TODO: I'm not sure DataPacketReceiveEvent should be included in the handler timings, but it needs to be
|
$decodeTimings = Timings::getDecodeDataPacketTimings($packet);
|
||||||
//included for now to ensure the receivePacket timings are counted the way they were before
|
$decodeTimings->startTiming();
|
||||||
$ev = new DataPacketReceiveEvent($this, $packet);
|
try{
|
||||||
$ev->call();
|
$stream = PacketSerializer::decoder($buffer, 0, $this->packetSerializerContext);
|
||||||
if(!$ev->isCancelled() && ($this->handler === null || !$packet->handle($this->handler))){
|
try{
|
||||||
$this->logger->debug("Unhandled " . $packet->getName() . ": " . base64_encode($stream->getBuffer()));
|
$packet->decode($stream);
|
||||||
|
}catch(PacketDecodeException $e){
|
||||||
|
throw PacketHandlingException::wrap($e);
|
||||||
|
}
|
||||||
|
if(!$stream->feof()){
|
||||||
|
$remains = substr($stream->getBuffer(), $stream->getOffset());
|
||||||
|
$this->logger->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": " . bin2hex($remains));
|
||||||
|
}
|
||||||
|
}finally{
|
||||||
|
$decodeTimings->stopTiming();
|
||||||
|
}
|
||||||
|
|
||||||
|
$handlerTimings = Timings::getHandleDataPacketTimings($packet);
|
||||||
|
$handlerTimings->startTiming();
|
||||||
|
try{
|
||||||
|
//TODO: I'm not sure DataPacketReceiveEvent should be included in the handler timings, but it needs to be
|
||||||
|
//included for now to ensure the receivePacket timings are counted the way they were before
|
||||||
|
$ev = new DataPacketReceiveEvent($this, $packet);
|
||||||
|
$ev->call();
|
||||||
|
if(!$ev->isCancelled() && ($this->handler === null || !$packet->handle($this->handler))){
|
||||||
|
$this->logger->debug("Unhandled " . $packet->getName() . ": " . base64_encode($stream->getBuffer()));
|
||||||
|
}
|
||||||
|
}finally{
|
||||||
|
$handlerTimings->stopTiming();
|
||||||
}
|
}
|
||||||
}finally{
|
}finally{
|
||||||
$timings->stopTiming();
|
$timings->stopTiming();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user