source: network-game/common/MessageContainer.h@ 1df6bec

Last change on this file since 1df6bec was 46d6469, checked in by dportnoy <dmp1488@…>, 11 years ago

Some bug fixes for MessageProcessor. MessageContainer is now in its own files.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#ifndef _MESSAGE_CONTAINER_H
2#define _MESSAGE_CONTAINER_H
3
4#include "Compiler.h"
5
6#if defined WINDOWS
7 #include <winsock2.h>
8 #include <WS2tcpip.h>
9#elif defined LINUX
10 #include <netinet/in.h>
11#endif
12
13#define MSG_TYPE_ACK 1
14#define MSG_TYPE_REGISTER 2
15#define MSG_TYPE_LOGIN 3
16#define MSG_TYPE_LOGOUT 4
17#define MSG_TYPE_CHAT 5
18#define MSG_TYPE_PLAYER 6 // server sends this to update player positions
19#define MSG_TYPE_PLAYER_MOVE 7 // client sends this when a player wants to move
20#define MSG_TYPE_OBJECT 8
21#define MSG_TYPE_REMOVE_OBJECT 9
22#define MSG_TYPE_PICKUP_FLAG 10
23#define MSG_TYPE_DROP_FLAG 11
24#define MSG_TYPE_SCORE 12
25#define MSG_TYPE_START_ATTACK 13
26#define MSG_TYPE_ATTACK 14
27#define MSG_TYPE_PROJECTILE 15
28#define MSG_TYPE_REMOVE_PROJECTILE 16
29
30typedef struct
31{
32 unsigned int id;
33 unsigned short type;
34 char buffer[256];
35} NETWORK_MSG;
36
37class MessageContainer {
38private:
39 NETWORK_MSG msg;
40 struct sockaddr_in clientAddr;
41 bool isAcked;
42 unsigned long long timeAcked;
43
44public:
45 MessageContainer();
46 MessageContainer(const MessageContainer& mc);
47 MessageContainer(NETWORK_MSG msg, struct sockaddr_in clientAddr);
48 ~MessageContainer();
49
50 bool getAcked();
51 unsigned long long getTimeAcked();
52 NETWORK_MSG* getMessage();
53
54 void setAcked(bool acked);
55 void setTimeAcked(unsigned long long time);
56};
57
58#endif
Note: See TracBrowser for help on using the repository browser.