improve packet interface

This commit is contained in:
2024-07-18 20:45:55 +02:00
parent 9fadb86031
commit 8bc2f26578
11 changed files with 400 additions and 79 deletions

View File

@@ -3,13 +3,15 @@
#include <blitz/protocol/PacketFactory.h>
#include <blitz/utils/Test.h>
static int Test() {
for (std::size_t i = 0; i < static_cast<std::size_t>(blitz::protocol::PacketType::PACKET_COUNT); i++) {
const auto& packet = blitz::protocol::PacketFactory::CreateReadOnlyPacket(blitz::protocol::PacketType(i));
namespace bp = blitz::protocol;
Nz::ByteArray buffer = blitz::protocol::PacketSerializer::Serialize(*packet.get());
static int TestAllPackets() {
for (std::size_t i = 0; i < static_cast<std::size_t>(bp::PacketType::PACKET_COUNT); i++) {
const auto& packet = bp::PacketFactory::CreateReadOnlyPacket(bp::PacketType(i));
blitz::protocol::PacketPtr packet2 = blitz::protocol::PacketSerializer::Deserialize(buffer);
Nz::ByteArray buffer = bp::PacketSerializer::Serialize(*packet.get());
bp::PacketPtr packet2 = bp::PacketSerializer::Deserialize(buffer);
blitz_test_assert(packet2 != nullptr);
@@ -18,6 +20,12 @@ static int Test() {
return 0;
}
static void Test() {
bp::packets::ChatMessage packet({"caca"});
Nz::ByteArray buffer = bp::PacketSerializer::Serialize(packet);
}
int main() {
return Test();
Test();
return TestAllPackets();
}