mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 11:58:00 +00:00
DataPacket no longer keeps its own serializer
since a while ago, we're anyway just discarding the internal buffer anyway when the packet is repeatedly encoded, so this doesn't serve any advantage anymore. We do need a system to be able to reuse encoded packet buffers, but right now we're not reusing them anyway.
This commit is contained in:
@@ -73,6 +73,7 @@ use pocketmine\network\mcpe\protocol\PlayerListPacket;
|
||||
use pocketmine\network\mcpe\protocol\PlayStatusPacket;
|
||||
use pocketmine\network\mcpe\protocol\RemoveActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketBatch;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
|
||||
use pocketmine\network\mcpe\protocol\ServerboundPacket;
|
||||
use pocketmine\network\mcpe\protocol\ServerToClientHandshakePacket;
|
||||
use pocketmine\network\mcpe\protocol\SetActorDataPacket;
|
||||
@@ -355,11 +356,11 @@ class NetworkSession{
|
||||
}
|
||||
|
||||
try{
|
||||
foreach($stream->getPackets($this->packetPool, 500) as $packet){
|
||||
foreach($stream->getPackets($this->packetPool, 500) as [$packet, $buffer]){
|
||||
try{
|
||||
$this->handleDataPacket($packet);
|
||||
$this->handleDataPacket($packet, $buffer);
|
||||
}catch(PacketHandlingException $e){
|
||||
$this->logger->debug($packet->getName() . ": " . base64_encode($packet->getSerializer()->getBuffer()));
|
||||
$this->logger->debug($packet->getName() . ": " . base64_encode($buffer));
|
||||
throw PacketHandlingException::wrap($e, "Error processing " . $packet->getName());
|
||||
}
|
||||
}
|
||||
@@ -372,10 +373,10 @@ class NetworkSession{
|
||||
/**
|
||||
* @throws PacketHandlingException
|
||||
*/
|
||||
public function handleDataPacket(Packet $packet) : void{
|
||||
public function handleDataPacket(Packet $packet, string $buffer) : void{
|
||||
if(!($packet instanceof ServerboundPacket)){
|
||||
if($packet instanceof GarbageServerboundPacket){
|
||||
$this->logger->debug("Garbage serverbound " . $packet->getName() . ": " . base64_encode($packet->getSerializer()->getBuffer()));
|
||||
$this->logger->debug("Garbage serverbound " . $packet->getName() . ": " . base64_encode($buffer));
|
||||
return;
|
||||
}
|
||||
throw new PacketHandlingException("Unexpected non-serverbound packet");
|
||||
@@ -385,12 +386,12 @@ class NetworkSession{
|
||||
$timings->startTiming();
|
||||
|
||||
try{
|
||||
$stream = new PacketSerializer($buffer);
|
||||
try{
|
||||
$packet->decode();
|
||||
$packet->decode($stream);
|
||||
}catch(PacketDecodeException $e){
|
||||
throw PacketHandlingException::wrap($e);
|
||||
}
|
||||
$stream = $packet->getSerializer();
|
||||
if(!$stream->feof()){
|
||||
$remains = substr($stream->getBuffer(), $stream->getOffset());
|
||||
$this->logger->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": " . bin2hex($remains));
|
||||
|
Reference in New Issue
Block a user