Last change
on this file since 13a8212 was 13a8212, checked in by Dmitry Portnoy <dmp1488@…>, 9 years ago |
In the MessageContainer, add a field for when the message was originally sent
|
-
Property mode
set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | #ifndef _MESSAGE_CONTAINER_H
|
---|
2 | #define _MESSAGE_CONTAINER_H
|
---|
3 |
|
---|
4 | #include <string>
|
---|
5 |
|
---|
6 | #include "Compiler.h"
|
---|
7 |
|
---|
8 | #if defined WINDOWS
|
---|
9 | #include <winsock2.h>
|
---|
10 | #elif defined LINUX
|
---|
11 | #include <netinet/in.h>
|
---|
12 | #elif defined MAC
|
---|
13 | #include <netinet/in.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | using namespace std;
|
---|
17 |
|
---|
18 | enum 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_PROFILE,
|
---|
35 | MSG_TYPE_CREATE_GAME,
|
---|
36 | MSG_TYPE_JOIN_GAME,
|
---|
37 | MSG_TYPE_LEAVE_GAME,
|
---|
38 | MSG_TYPE_GAME_INFO,
|
---|
39 | MSG_TYPE_CREATE_GAME_FAILURE,
|
---|
40 | MSG_TYPE_JOIN_GAME_SUCCESS,
|
---|
41 | MSG_TYPE_JOIN_GAME_FAILURE,
|
---|
42 | MSG_TYPE_JOIN_GAME_ACK,
|
---|
43 | MSG_TYPE_PLAYER_JOIN_GAME,
|
---|
44 | MSG_TYPE_FINISH_GAME,
|
---|
45 | MSG_TYPE_JOIN_TEAM,
|
---|
46 | MSG_TYPE_START_GAME
|
---|
47 | };
|
---|
48 |
|
---|
49 | typedef struct
|
---|
50 | {
|
---|
51 | unsigned int id;
|
---|
52 | unsigned short type;
|
---|
53 | char buffer[256];
|
---|
54 | } NETWORK_MSG;
|
---|
55 |
|
---|
56 | class MessageContainer {
|
---|
57 | private:
|
---|
58 | NETWORK_MSG msg;
|
---|
59 | struct sockaddr_in clientAddr;
|
---|
60 | bool isAcked;
|
---|
61 | unsigned long long timeSent;
|
---|
62 | unsigned long long timeAcked;
|
---|
63 |
|
---|
64 | public:
|
---|
65 | MessageContainer();
|
---|
66 | MessageContainer(const MessageContainer& mc);
|
---|
67 | MessageContainer(NETWORK_MSG msg, struct sockaddr_in clientAddr);
|
---|
68 | ~MessageContainer();
|
---|
69 |
|
---|
70 | NETWORK_MSG* getMessage();
|
---|
71 | bool getAcked();
|
---|
72 | unsigned long long getTimeSent();
|
---|
73 | unsigned long long getTimeAcked();
|
---|
74 |
|
---|
75 | void setAcked(bool acked);
|
---|
76 | void setTimeSent(unsigned long long time);
|
---|
77 | void setTimeAcked(unsigned long long time);
|
---|
78 |
|
---|
79 | static string getMsgTypeString(int msgType);
|
---|
80 | };
|
---|
81 |
|
---|
82 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.