Last change
on this file since 9ee50ce was 06fc7f7, checked in by dportnoy <dmp1488@…>, 11 years ago |
getMsgTypeString is now defined in MessageContainer.cpp and the message types have been converted to an enum
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[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>
|
---|
| 12 | #endif
|
---|
| 13 |
|
---|
[b35b2b2] | 14 | using namespace std;
|
---|
| 15 |
|
---|
[06fc7f7] | 16 | enum MessageType {
|
---|
| 17 | MSG_TYPE_ACK = 1,
|
---|
| 18 | MSG_TYPE_REGISTER,
|
---|
| 19 | MSG_TYPE_LOGIN,
|
---|
| 20 | MSG_TYPE_LOGOUT,
|
---|
| 21 | MSG_TYPE_CHAT,
|
---|
| 22 | MSG_TYPE_PLAYER,
|
---|
| 23 | MSG_TYPE_PLAYER_MOVE,
|
---|
| 24 | MSG_TYPE_OBJECT,
|
---|
| 25 | MSG_TYPE_REMOVE_OBJECT,
|
---|
| 26 | MSG_TYPE_PICKUP_FLAG,
|
---|
| 27 | MSG_TYPE_DROP_FLAG,
|
---|
| 28 | MSG_TYPE_SCORE,
|
---|
| 29 | MSG_TYPE_ATTACK,
|
---|
| 30 | MSG_TYPE_PROJECTILE,
|
---|
| 31 | MSG_TYPE_REMOVE_PROJECTILE,
|
---|
| 32 | MSG_TYPE_CREATE_GAME,
|
---|
| 33 | MSG_TYPE_JOIN_GAME,
|
---|
| 34 | MSG_TYPE_LEAVE_GAME,
|
---|
| 35 | MSG_TYPE_GAME_INFO,
|
---|
| 36 | MSG_TYPE_JOIN_GAME_SUCCESS,
|
---|
| 37 | MSG_TYPE_JOIN_GAME_FAILURE,
|
---|
| 38 | MSG_TYPE_JOIN_GAME_ACK,
|
---|
| 39 | MSG_TYPE_PLAYER_JOIN_GAME,
|
---|
| 40 | MSG_TYPE_FINISH_GAME
|
---|
| 41 | };
|
---|
[46d6469] | 42 |
|
---|
| 43 | typedef struct
|
---|
| 44 | {
|
---|
| 45 | unsigned int id;
|
---|
| 46 | unsigned short type;
|
---|
| 47 | char buffer[256];
|
---|
| 48 | } NETWORK_MSG;
|
---|
| 49 |
|
---|
| 50 | class MessageContainer {
|
---|
| 51 | private:
|
---|
| 52 | NETWORK_MSG msg;
|
---|
| 53 | struct sockaddr_in clientAddr;
|
---|
| 54 | bool isAcked;
|
---|
| 55 | unsigned long long timeAcked;
|
---|
| 56 |
|
---|
| 57 | public:
|
---|
| 58 | MessageContainer();
|
---|
| 59 | MessageContainer(const MessageContainer& mc);
|
---|
| 60 | MessageContainer(NETWORK_MSG msg, struct sockaddr_in clientAddr);
|
---|
| 61 | ~MessageContainer();
|
---|
| 62 |
|
---|
| 63 | bool getAcked();
|
---|
| 64 | unsigned long long getTimeAcked();
|
---|
| 65 | NETWORK_MSG* getMessage();
|
---|
| 66 |
|
---|
| 67 | void setAcked(bool acked);
|
---|
| 68 | void setTimeAcked(unsigned long long time);
|
---|
[b35b2b2] | 69 |
|
---|
[06fc7f7] | 70 | static string getMsgTypeString(int msgType);
|
---|
[46d6469] | 71 | };
|
---|
| 72 |
|
---|
| 73 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.