diff --git a/include/examples/KeepAlivePacket.h b/include/examples/KeepAlivePacket.h new file mode 100644 index 0000000..980ffa1 --- /dev/null +++ b/include/examples/KeepAlivePacket.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include +#include + +enum PacketId { + KeepAlive = 0, +}; + +enum KeepAlivePacketFields { + KeepAliveId = 0 +}; + +using KeepAliveFields = std::tuple>; + +class KeepAlivePacket : public sp::MessageBase, // provide idImpl() if needed + sp::option::DispatchImpl, // provide dispatchImpl() if needed + sp::option::FieldsImpl // provide access to fields + > {}; \ No newline at end of file diff --git a/include/examples/PacketExample.h b/include/examples/PacketExample.h index da9fbec..c4f068d 100644 --- a/include/examples/PacketExample.h +++ b/include/examples/PacketExample.h @@ -1,20 +1,6 @@ #pragma once -#include -#include -#include - -enum PacketId { - KeepAlive = 0, -}; - -using KeepAliveFields = std::tuple>; - -class KeepAlivePacket : public sp::MessageBase, // provide idImpl() if needed - sp::option::DispatchImpl, // provide dispatchImpl() if needed - sp::option::FieldsImpl // provide access to fields - > {}; +#include using AllPackets = std::tuple; diff --git a/src/main.cpp b/src/main.cpp index 7f2a44a..9c0f3e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,8 +10,20 @@ class KeepAliveHandler : public sp::PacketHandler { }; int main() { - std::unique_ptr msg = std::make_unique(); + auto keepAlive = std::make_unique(); + sp::PacketMessage* msg = keepAlive.get(); + KeepAliveHandler handler; msg->Dispatch(handler); + + keepAlive->GetField() = 69; + sp::DataBuffer buffer; + msg->Write(buffer); + + auto keepAlive2 = std::make_unique(); + keepAlive2->Read(buffer); + + std::cout << "KeepAlive2 : " << keepAlive2->GetField() << "\n"; + return 0; } \ No newline at end of file