summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--messages.cpp14
-rw-r--r--messages.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/messages.cpp b/messages.cpp
index b7b7b38..ff4a6db 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -75,21 +75,35 @@ Pos::Pos() {
Pos::Pos(Vector3 pos) {
type = MSG_TYPE_POS;
+ this->id = 0;
+ this->pos = pos;
+}
+
+Pos::Pos(uint32_t id, Vector3 pos) {
+ type = MSG_TYPE_POS;
+
+ this->id = id;
this->pos = pos;
}
void Pos::do_send(boost::asio::ip::tcp::socket& socket) {
+ write(socket, id);
write(socket, pos.x);
write(socket, pos.y);
write(socket, pos.z);
}
void Pos::recv(boost::asio::ip::tcp::socket& socket) {
+ read(socket, id);
read(socket, pos.x);
read(socket, pos.y);
read(socket, pos.z);
}
+uint32_t Pos::get_id() {
+ return id;
+}
+
Vector3 Pos::get_pos() {
return pos;
}
diff --git a/messages.h b/messages.h
index 62f5a03..743914e 100644
--- a/messages.h
+++ b/messages.h
@@ -64,6 +64,7 @@ class Hello : public MessageBase {
class Pos : public MessageBase {
protected:
+ uint32_t id;
Vector3 pos;
virtual void do_send(boost::asio::ip::tcp::socket& socket);
@@ -71,9 +72,11 @@ class Pos : public MessageBase {
public:
Pos();
Pos(Vector3 pos);
+ Pos(uint32_t id, Vector3 pos);
virtual void recv(boost::asio::ip::tcp::socket& socket);
+ uint32_t get_id();
Vector3 get_pos();
};