diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-11-08 16:06:22 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-11-08 16:06:22 +0100 |
commit | c9b9d15a585df8f01b49510e4ff0dfb53ee7b9ef (patch) | |
tree | 4bec517a83bca880c459f36fc99242f902874a87 /common/payload.h | |
parent | 2b73fe37b292c22dbc823fe9a225dd2826cdff1d (diff) |
Started on payload classes.
Diffstat (limited to 'common/payload.h')
-rw-r--r-- | common/payload.h | 49 |
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 |