1 | #include "MessageContainer.h"
|
---|
2 |
|
---|
3 | #include <iostream>
|
---|
4 |
|
---|
5 | #include "Compiler.h"
|
---|
6 |
|
---|
7 | using namespace std;
|
---|
8 |
|
---|
9 | MessageContainer::MessageContainer() {
|
---|
10 | }
|
---|
11 |
|
---|
12 | MessageContainer::MessageContainer(const MessageContainer& mc) {
|
---|
13 | this->msg = mc.msg;
|
---|
14 | this->clientAddr = mc.clientAddr;
|
---|
15 | this->isAcked = mc.isAcked;
|
---|
16 | this->timeAcked = mc.timeAcked;
|
---|
17 | }
|
---|
18 |
|
---|
19 | MessageContainer::MessageContainer(NETWORK_MSG msg, struct sockaddr_in clientAddr) {
|
---|
20 | this->clientAddr = clientAddr;
|
---|
21 | this->msg = msg;
|
---|
22 | this->isAcked = false;
|
---|
23 | this->timeAcked = 0;
|
---|
24 | }
|
---|
25 |
|
---|
26 | MessageContainer::~MessageContainer() {
|
---|
27 | }
|
---|
28 |
|
---|
29 | bool MessageContainer::getAcked() {
|
---|
30 | return this->isAcked;
|
---|
31 | }
|
---|
32 |
|
---|
33 | unsigned long long MessageContainer::getTimeAcked() {
|
---|
34 | return this->timeAcked;
|
---|
35 | }
|
---|
36 |
|
---|
37 | NETWORK_MSG* MessageContainer::getMessage() {
|
---|
38 | return &msg;
|
---|
39 | }
|
---|
40 |
|
---|
41 | void MessageContainer::setAcked(bool acked) {
|
---|
42 | cout << "acked before: " << this->isAcked << endl;
|
---|
43 | this->isAcked = acked;
|
---|
44 | cout << "acked after: " << this->isAcked << endl;
|
---|
45 | }
|
---|
46 |
|
---|
47 | void MessageContainer::setTimeAcked(unsigned long long time) {
|
---|
48 | this->timeAcked = time;
|
---|
49 | }
|
---|
50 |
|
---|
51 | /*
|
---|
52 | string getMsgTypeString(int msgType) {
|
---|
53 | switch(msgType) {
|
---|
54 | case MSG_TYPE_ACK: return "MSG_TYPE_ACK";
|
---|
55 | case MSG_TYPE_REGISTER: return "MSG_TYPE_REGISTER";
|
---|
56 | case MSG_TYPE_LOGIN: return "MSG_TYPE_LOGIN";
|
---|
57 | case MSG_TYPE_LOGOUT: return "MSG_TYPE_LOGOUT";
|
---|
58 | case MSG_TYPE_CHAT: return "MSG_TYPE_CHAT";
|
---|
59 | case MSG_TYPE_PLAYER: return "MSG_TYPE_PLAYER";
|
---|
60 | case MSG_TYPE_PLAYER_MOVE: return "MSG_TYPE_PLAYER_MOVE";
|
---|
61 | case MSG_TYPE_OBJECT: return "MSG_TYPE_OBJECT";
|
---|
62 | case MSG_TYPE_REMOVE_OBJECT: return "MSG_TYPE_REMOVE_OBJECT";
|
---|
63 | case MSG_TYPE_PICKUP_FLAG: return "MSG_TYPE_PICKUP_FLAG";
|
---|
64 | caseMSG_TYPE_DROP_FLAG: return "MSG_TYPE_DROP_FLAG";
|
---|
65 | case MSG_TYPE_SCORE: return "MSG_TYPE_SCORE";
|
---|
66 | case MSG_TYPE_START_ATTACK: return "MSG_TYPE_START_ATACK";
|
---|
67 | case MSG_TYPE_ATTACK: return "MSG_TYPE_ATTACK";
|
---|
68 | case MSG_TYPE_PROJECTILE: return "MSG_TYPE_PROJECTILE";
|
---|
69 | case MSG_TYPE_REMOVE_PROJECTILE: return "MSG_TYPE_REMOVE_PROJECTILE";
|
---|
70 | default: return "Unknown";
|
---|
71 | }
|
---|
72 | }
|
---|
73 | */
|
---|