summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/connectionbase.cpp16
-rw-r--r--common/message.cpp33
-rw-r--r--common/message.h34
3 files changed, 83 insertions, 0 deletions
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<Message::GameStart>();
break;
+ case Message::Types::Ready:
+ m = make_shared<Message::Ready>();
+ break;
+
+ case Message::Types::RoundStart:
+ m = make_shared<Message::RoundStart>();
+ break;
+
+ case Message::Types::RoundState:
+ m = make_shared<Message::RoundState>();
+ break;
+
+ case Message::Types::RoundAction:
+ m = make_shared<Message::RoundAction>();
+ 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 <boost/serialization/vector.hpp>
#include <boost/serialization/string.hpp>
+#include <boost/serialization/shared_ptr.hpp>
#include <cstring>
#include <sstream>
@@ -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 <vector>
#include <string>
+#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<RoundStart> p;
+
+ RoundStart();
+ };
+
+ class RoundState : public BoostBase {
+ public:
+ typedef boost::shared_ptr<RoundState> 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<RoundAction> p;
+
+ RoundAction();
+
+ Action action;
+
+ virtual void serialize(boost::archive::text_oarchive& ar);
+ virtual void deserialize(boost::archive::text_iarchive& ar);
+ };
+
typedef boost::shared_ptr<Base> p;
};