working message factory

This commit is contained in:
2025-02-06 22:16:07 +01:00
parent f5430f3d0f
commit bbafae2588
5 changed files with 105 additions and 4 deletions

View File

@@ -7,6 +7,10 @@ class KeepAliveHandler : public sp::PacketHandler {
void Handle(KeepAlivePacket& packet) {
std::cout << "KeepAlive handled !\n";
}
void Handle(DisconnectPacket& packet) {
std::cout << "Disconnect handled !\n";
}
};
int main() {
@@ -24,7 +28,15 @@ int main() {
std::cout << "KeepAlive2 : " << keepAlive2->GetField<KeepAliveId>() << "\n";
//TODO: write ID and factory
//TODO: write ID
sp::PacketFactory factory;
auto packet = factory.CreateMessage(Disconnect);
if (packet == nullptr) {
std::cout << "Mauvais ID !\n";
return 1;
}
std::cout << (unsigned) packet->GetId() << std::endl;
packet->Dispatch(handler);
return 0;
}