[46d6469] | 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 |
|
---|
[06fc7f7] | 45 |
|
---|
[46d6469] | 46 | void MessageContainer::setTimeAcked(unsigned long long time) {
|
---|
| 47 | this->timeAcked = time;
|
---|
| 48 | }
|
---|
[b35b2b2] | 49 |
|
---|
[06fc7f7] | 50 | string MessageContainer::getMsgTypeString(int msgType) {
|
---|
[b35b2b2] | 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";
|
---|
[06fc7f7] | 62 | case MSG_TYPE_DROP_FLAG: return "MSG_TYPE_DROP_FLAG";
|
---|
[b35b2b2] | 63 | case MSG_TYPE_SCORE: return "MSG_TYPE_SCORE";
|
---|
| 64 | case MSG_TYPE_ATTACK: return "MSG_TYPE_ATTACK";
|
---|
| 65 | case MSG_TYPE_PROJECTILE: return "MSG_TYPE_PROJECTILE";
|
---|
| 66 | case MSG_TYPE_REMOVE_PROJECTILE: return "MSG_TYPE_REMOVE_PROJECTILE";
|
---|
[06fc7f7] | 67 | case MSG_TYPE_CREATE_GAME: return "MSG_TYPE_CREATE_GAME";
|
---|
| 68 | case MSG_TYPE_JOIN_GAME: return "MSG_TYPE_JOIN_GAME";
|
---|
| 69 | case MSG_TYPE_LEAVE_GAME: return "MSG_TYPE_LEAVE_GAME";
|
---|
| 70 | case MSG_TYPE_GAME_INFO: return "MSG_TYPE_GAME_INFO";
|
---|
| 71 | case MSG_TYPE_JOIN_GAME_SUCCESS: return "MSG_TYPE_JOIN_GAME_SUCCESS";
|
---|
| 72 | case MSG_TYPE_JOIN_GAME_FAILURE: return "MSG_TYPE_JOIN_GAME_FAILURE";
|
---|
| 73 | case MSG_TYPE_JOIN_GAME_ACK: return "MSG_TYPE_JOIN_GAME_ACK";
|
---|
| 74 | case MSG_TYPE_PLAYER_JOIN_GAME: return "MSG_TYPE_PLAYER_JOIN_GAME";
|
---|
| 75 | case MSG_TYPE_FINISH_GAME: return "MSG_TYPE_FINISH_GAME";
|
---|
[b35b2b2] | 76 | default: return "Unknown";
|
---|
| 77 | }
|
---|
| 78 | }
|
---|