mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 08:35:20 +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:
@ -32,11 +32,11 @@ class DataPacketTest extends TestCase{
|
||||
$pk = new TestPacket();
|
||||
$pk->senderSubId = 3;
|
||||
$pk->recipientSubId = 2;
|
||||
$pk->encode();
|
||||
$serializer = new PacketSerializer();
|
||||
$pk->encode($serializer);
|
||||
|
||||
$pk2 = new TestPacket();
|
||||
$pk2->setSerializer(new PacketSerializer($pk->getSerializer()->getBuffer()));
|
||||
$pk2->decode();
|
||||
$pk2->decode(new PacketSerializer($serializer->getBuffer()));
|
||||
self::assertSame($pk2->senderSubId, 3);
|
||||
self::assertSame($pk2->recipientSubId, 2);
|
||||
}
|
||||
|
@ -43,6 +43,6 @@ class LoginPacketTest extends TestCase{
|
||||
$pk = PacketPool::getInstance()->getPacket($stream->getBuffer());
|
||||
|
||||
$this->expectException(PacketDecodeException::class);
|
||||
$pk->decode(); //bang
|
||||
$pk->decode(new PacketSerializer($stream->getBuffer())); //bang
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user