source: network-game/common/MessageContainer.h@ ea17281

Last change on this file since ea17281 was 34bd549, checked in by Dmitry Portnoy <dmp1488@…>, 10 years ago

Make client compile on a Mac

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[46d6469]1#ifndef _MESSAGE_CONTAINER_H
2#define _MESSAGE_CONTAINER_H
3
[b35b2b2]4#include <string>
5
[e6c26b8]6#include "Compiler.h"
[46d6469]7
[e6c26b8]8#if defined WINDOWS
9 #include <winsock2.h>
10#elif defined LINUX
[373089e]11 #include <netinet/in.h>
[34bd549]12#elif defined MAC
13 #include <netinet/in.h>
[373089e]14#endif
15
[b35b2b2]16using namespace std;
17
[06fc7f7]18enum MessageType {
19 MSG_TYPE_ACK = 1,
20 MSG_TYPE_REGISTER,
21 MSG_TYPE_LOGIN,
22 MSG_TYPE_LOGOUT,
23 MSG_TYPE_CHAT,
24 MSG_TYPE_PLAYER,
25 MSG_TYPE_PLAYER_MOVE,
26 MSG_TYPE_OBJECT,
27 MSG_TYPE_REMOVE_OBJECT,
28 MSG_TYPE_PICKUP_FLAG,
29 MSG_TYPE_DROP_FLAG,
30 MSG_TYPE_SCORE,
31 MSG_TYPE_ATTACK,
32 MSG_TYPE_PROJECTILE,
33 MSG_TYPE_REMOVE_PROJECTILE,
34 MSG_TYPE_CREATE_GAME,
35 MSG_TYPE_JOIN_GAME,
36 MSG_TYPE_LEAVE_GAME,
37 MSG_TYPE_GAME_INFO,
38 MSG_TYPE_JOIN_GAME_SUCCESS,
39 MSG_TYPE_JOIN_GAME_FAILURE,
40 MSG_TYPE_JOIN_GAME_ACK,
41 MSG_TYPE_PLAYER_JOIN_GAME,
42 MSG_TYPE_FINISH_GAME
43};
[46d6469]44
45typedef struct
46{
47 unsigned int id;
48 unsigned short type;
49 char buffer[256];
50} NETWORK_MSG;
51
52class MessageContainer {
53private:
54 NETWORK_MSG msg;
55 struct sockaddr_in clientAddr;
56 bool isAcked;
57 unsigned long long timeAcked;
58
59public:
60 MessageContainer();
61 MessageContainer(const MessageContainer& mc);
62 MessageContainer(NETWORK_MSG msg, struct sockaddr_in clientAddr);
63 ~MessageContainer();
64
65 bool getAcked();
66 unsigned long long getTimeAcked();
67 NETWORK_MSG* getMessage();
68
69 void setAcked(bool acked);
70 void setTimeAcked(unsigned long long time);
[b35b2b2]71
[06fc7f7]72 static string getMsgTypeString(int msgType);
[46d6469]73};
74
75#endif
Note: See TracBrowser for help on using the repository browser.