From a5fbbe1c51968d330f1621efb5bf5d3b3c4ddf4d Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Fri, 19 Nov 2010 17:51:54 +0100 Subject: Add RoundStart, RoundState and RoundAction messages. --- common/connectionbase.cpp | 16 ++++++++++++++++ common/message.cpp | 33 +++++++++++++++++++++++++++++++++ common/message.h | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/common/connectionbase.cpp b/common/connectionbase.cpp index ce23752..66b5140 100644 --- a/common/connectionbase.cpp +++ b/common/connectionbase.cpp @@ -54,6 +54,22 @@ void ConnectionBase::got_data(uint8_t* data, std::size_t bytes) { m = make_shared(); break; + case Message::Types::Ready: + m = make_shared(); + break; + + case Message::Types::RoundStart: + m = make_shared(); + break; + + case Message::Types::RoundState: + m = make_shared(); + break; + + case Message::Types::RoundAction: + m = make_shared(); + break; + default: throw std::runtime_error("Deserialization attempted on unknown message type."); } diff --git a/common/message.cpp b/common/message.cpp index a72bac9..bc0e3dd 100644 --- a/common/message.cpp +++ b/common/message.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -124,3 +125,35 @@ void Message::GameStart::deserialize(boost::archive::text_iarchive& ar) { Message::Ready::Ready() : NullBase(Types::Ready) { } + +Message::RoundStart::RoundStart() : NullBase(Types::RoundStart) { + +} + +Message::RoundState::RoundState() : BoostBase(Types::RoundState) { + +} + +Message::RoundState::RoundState(State::p state_) : BoostBase(Types::RoundState), state(state_) { + +} + +void Message::RoundState::serialize(boost::archive::text_oarchive& ar) { + ar & state; +} + +void Message::RoundState::deserialize(boost::archive::text_iarchive& ar) { + ar & state; +} + +Message::RoundAction::RoundAction() : BoostBase(Types::RoundAction) { + +} + +void Message::RoundAction::serialize(boost::archive::text_oarchive& ar) { + ar & action; +} + +void Message::RoundAction::deserialize(boost::archive::text_iarchive& ar) { + ar & action; +} diff --git a/common/message.h b/common/message.h index 6b2744d..26deb32 100644 --- a/common/message.h +++ b/common/message.h @@ -13,6 +13,8 @@ using boost::dynamic_pointer_cast; #include #include +#include "state.h" + namespace Message { namespace Types { //! Message types. @@ -124,6 +126,38 @@ namespace Message { Ready(); }; + class RoundStart : public NullBase { + public: + typedef boost::shared_ptr p; + + RoundStart(); + }; + + class RoundState : public BoostBase { + public: + typedef boost::shared_ptr p; + + RoundState(); + RoundState(State::p state_); + + State::p state; + + virtual void serialize(boost::archive::text_oarchive& ar); + virtual void deserialize(boost::archive::text_iarchive& ar); + }; + + class RoundAction : public BoostBase { + public: + typedef boost::shared_ptr p; + + RoundAction(); + + Action action; + + virtual void serialize(boost::archive::text_oarchive& ar); + virtual void deserialize(boost::archive::text_iarchive& ar); + }; + typedef boost::shared_ptr p; }; -- cgit v1.2.3