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:
Dylan K. Taylor
2021-04-09 15:37:58 +01:00
parent 19f536d68a
commit 0312b62c8a
7 changed files with 29 additions and 50 deletions

View File

@ -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);
}

View File

@ -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
}
}