use generic handler
All checks were successful
Linux arm64 / Build (push) Successful in 15s

This commit is contained in:
2025-07-18 16:45:27 +02:00
parent 2149172b41
commit 143b2f357c
3 changed files with 28 additions and 145 deletions

View File

@@ -1,16 +1,16 @@
#include <sp/protocol/ConcreteMessage.h>
#include <sp/protocol/MessageDispatcher.h>
#include <sp/protocol/MessageFactory.h>
#include <sp/protocol/MessageHandler.h>
#include <sp/common/GenericHandler.h>
#include <sp/io/MessageStream.h>
#include <sp/io/StdIo.h>
#include <sp/protocol/BitField.h>
#include <sp/protocol/ConcreteMessage.h>
#include <sp/protocol/MessageDispatcher.h>
#include <sp/protocol/MessageFactory.h>
#include <sp/extensions/Compress.h>
#include <cstdint>
#include <iostream>
#include <fstream>
#include <iostream>
enum class PacketID { KeepAlive = 0 };
@@ -30,12 +30,12 @@ using KeepAliveMessage = Message<KeepAlivePacket, PacketID::KeepAlive>;
using AllMessages = std::tuple<KeepAliveMessage>;
class PacketHandler : public sp::MessageHandler<AllMessages> {};
class PacketHandler : public sp::GenericHandler<AllMessages> {};
class MyHandler : public PacketHandler {
public:
virtual void Handle(const KeepAlivePacket& msg) {
std::cout << "I recieved a keep alive : " << *msg.one << " : " << *msg.two << "\n";
virtual void Handle(const KeepAliveMessage& msg) override {
std::cout << "I recieved a keep alive : " << *msg->one << " : " << *msg->two << "\n";
}
};
@@ -64,17 +64,17 @@ int main() {
auto compress = std::make_shared<sp::ZlibCompress>();
std::ofstream file {"test.bin"};
std::ofstream file{"test.bin"};
PacketStream p(std::make_shared<sp::StdOuput>(file), compress);
PacketStream p(std::make_shared<sp::StdOuput>(file));
p.WriteMessage(m);
file.flush();
std::ifstream file2 {"test.bin"};
std::ifstream file2{"test.bin"};
PacketStream p2(std::make_shared<sp::StdInput>(file2), compress);
PacketStream p2(std::make_shared<sp::StdInput>(file2));
auto message2 = p2.ReadMessage();