diff options
Diffstat (limited to 'common/message.h')
-rw-r--r-- | common/message.h | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/common/message.h b/common/message.h index b2d3078..bd68efe 100644 --- a/common/message.h +++ b/common/message.h @@ -6,7 +6,11 @@ using boost::make_shared; using boost::dynamic_pointer_cast; +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> + #include <stdint.h> +#include <vector> #include <string> namespace Message { @@ -32,7 +36,7 @@ namespace Message { class Base { protected: - Base(Type t) : type(t) {} + Base(Type t); public: const Type type; @@ -41,6 +45,27 @@ namespace Message { virtual void deserialize(uint8_t* data, std::size_t bytes) = 0; }; + class NullBase : public Base { + protected: + NullBase(Type t); + + public: + virtual std::pair<uint8_t*, std::size_t> serialize(); + virtual void deserialize(uint8_t* data, std::size_t bytes); + }; + + class BoostBase : public Base { + protected: + BoostBase(Type t); + + public: + virtual std::pair<uint8_t*, std::size_t> serialize(); + virtual void deserialize(uint8_t* data, std::size_t bytes); + + virtual void serialize(boost::archive::text_oarchive& ar) = 0; + virtual void deserialize(boost::archive::text_iarchive& ar) = 0; + }; + class Hello : public Base { public: typedef boost::shared_ptr<Hello> p; @@ -80,24 +105,23 @@ namespace Message { virtual void deserialize(uint8_t* data, std::size_t bytes); }; - class GameStart : public Base { + class GameStart : public BoostBase { public: typedef boost::shared_ptr<LoginResponse> p; GameStart(); - virtual std::pair<uint8_t*, std::size_t> serialize(); - virtual void deserialize(uint8_t* data, std::size_t bytes); + std::vector<std::string> players; + + virtual void serialize(boost::archive::text_oarchive& ar); + virtual void deserialize(boost::archive::text_iarchive& ar); }; - class Ready : public Base { + class Ready : public NullBase { public: typedef boost::shared_ptr<Ready> p; Ready(); - - virtual std::pair<uint8_t*, std::size_t> serialize(); - virtual void deserialize(uint8_t* data, std::size_t bytes); }; typedef boost::shared_ptr<Base> p; |