[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;
|
---|
[13a8212] | 13 | this->timeSent = mc.timeSent;
|
---|
[46d6469] | 14 | this->isAcked = mc.isAcked;
|
---|
| 15 | this->timeAcked = mc.timeAcked;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | MessageContainer::MessageContainer(NETWORK_MSG msg, struct sockaddr_in clientAddr) {
|
---|
| 19 | this->clientAddr = clientAddr;
|
---|
| 20 | this->msg = msg;
|
---|
[13a8212] | 21 | this->timeSent = 0;
|
---|
[46d6469] | 22 | this->isAcked = false;
|
---|
| 23 | this->timeAcked = 0;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | MessageContainer::~MessageContainer() {
|
---|
| 27 | }
|
---|
| 28 |
|
---|
[13a8212] | 29 | NETWORK_MSG* MessageContainer::getMessage() {
|
---|
| 30 | return &msg;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
[46d6469] | 33 | bool MessageContainer::getAcked() {
|
---|
| 34 | return this->isAcked;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
[13a8212] | 37 | unsigned long long MessageContainer::getTimeSent() {
|
---|
| 38 | return this->timeSent;
|
---|
[46d6469] | 39 | }
|
---|
| 40 |
|
---|
[13a8212] | 41 | unsigned long long MessageContainer::getTimeAcked() {
|
---|
| 42 | return this->timeAcked;
|
---|
[46d6469] | 43 | }
|
---|
| 44 |
|
---|
| 45 | void MessageContainer::setAcked(bool acked) {
|
---|
| 46 | this->isAcked = acked;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[13a8212] | 49 | void MessageContainer::setTimeSent(unsigned long long time) {
|
---|
| 50 | this->timeSent = time;
|
---|
| 51 | }
|
---|
[06fc7f7] | 52 |
|
---|
[46d6469] | 53 | void MessageContainer::setTimeAcked(unsigned long long time) {
|
---|
| 54 | this->timeAcked = time;
|
---|
| 55 | }
|
---|
[b35b2b2] | 56 |
|
---|
[06fc7f7] | 57 | string MessageContainer::getMsgTypeString(int msgType) {
|
---|
[b35b2b2] | 58 | switch(msgType) {
|
---|
| 59 | case MSG_TYPE_ACK: return "MSG_TYPE_ACK";
|
---|
| 60 | case MSG_TYPE_REGISTER: return "MSG_TYPE_REGISTER";
|
---|
| 61 | case MSG_TYPE_LOGIN: return "MSG_TYPE_LOGIN";
|
---|
| 62 | case MSG_TYPE_LOGOUT: return "MSG_TYPE_LOGOUT";
|
---|
| 63 | case MSG_TYPE_CHAT: return "MSG_TYPE_CHAT";
|
---|
| 64 | case MSG_TYPE_PLAYER: return "MSG_TYPE_PLAYER";
|
---|
| 65 | case MSG_TYPE_PLAYER_MOVE: return "MSG_TYPE_PLAYER_MOVE";
|
---|
| 66 | case MSG_TYPE_OBJECT: return "MSG_TYPE_OBJECT";
|
---|
| 67 | case MSG_TYPE_REMOVE_OBJECT: return "MSG_TYPE_REMOVE_OBJECT";
|
---|
| 68 | case MSG_TYPE_PICKUP_FLAG: return "MSG_TYPE_PICKUP_FLAG";
|
---|
[06fc7f7] | 69 | case MSG_TYPE_DROP_FLAG: return "MSG_TYPE_DROP_FLAG";
|
---|
[b35b2b2] | 70 | case MSG_TYPE_SCORE: return "MSG_TYPE_SCORE";
|
---|
| 71 | case MSG_TYPE_ATTACK: return "MSG_TYPE_ATTACK";
|
---|
| 72 | case MSG_TYPE_PROJECTILE: return "MSG_TYPE_PROJECTILE";
|
---|
| 73 | case MSG_TYPE_REMOVE_PROJECTILE: return "MSG_TYPE_REMOVE_PROJECTILE";
|
---|
[06fc7f7] | 74 | case MSG_TYPE_CREATE_GAME: return "MSG_TYPE_CREATE_GAME";
|
---|
| 75 | case MSG_TYPE_JOIN_GAME: return "MSG_TYPE_JOIN_GAME";
|
---|
| 76 | case MSG_TYPE_LEAVE_GAME: return "MSG_TYPE_LEAVE_GAME";
|
---|
| 77 | case MSG_TYPE_GAME_INFO: return "MSG_TYPE_GAME_INFO";
|
---|
| 78 | case MSG_TYPE_JOIN_GAME_SUCCESS: return "MSG_TYPE_JOIN_GAME_SUCCESS";
|
---|
| 79 | case MSG_TYPE_JOIN_GAME_FAILURE: return "MSG_TYPE_JOIN_GAME_FAILURE";
|
---|
| 80 | case MSG_TYPE_JOIN_GAME_ACK: return "MSG_TYPE_JOIN_GAME_ACK";
|
---|
| 81 | case MSG_TYPE_PLAYER_JOIN_GAME: return "MSG_TYPE_PLAYER_JOIN_GAME";
|
---|
| 82 | case MSG_TYPE_FINISH_GAME: return "MSG_TYPE_FINISH_GAME";
|
---|
[b35b2b2] | 83 | default: return "Unknown";
|
---|
| 84 | }
|
---|
| 85 | }
|
---|