summaryrefslogtreecommitdiff
path: root/common/payload.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/payload.h')
-rw-r--r--common/payload.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/common/payload.h b/common/payload.h
new file mode 100644
index 0000000..fbdcd1d
--- /dev/null
+++ b/common/payload.h
@@ -0,0 +1,49 @@
+#ifndef PAYLOAD_H
+#define PAYLOAD_H
+
+#include <utility>
+#include <stdint.h>
+
+namespace Payload {
+ namespace Types {
+ //! Payload types.
+ enum Type {
+ Undefined,
+ Hello,
+ Login,
+ LoginResponse,
+ LobbyStatus,
+ LobbyAction,
+ GameStart,
+ Ready,
+ RoundStart,
+ RoundState,
+ RoundAction,
+ RoundEnd,
+ GameEnd
+ };
+ }
+ using Types::Type;
+
+ class Base {
+ protected:
+ friend class Message;
+
+ virtual std::pair<uint8_t*, std::size_t> serialize() = 0;
+
+ Base(Type t) : type(t) {}
+
+ public:
+ const Type type;
+ };
+
+ class Hello : public Base {
+ protected:
+ virtual std::pair<uint8_t*, std::size_t> serialize();
+
+ public:
+ Hello() : Base(Types::Hello) {}
+ };
+};
+
+#endif