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