forked from tomdev2008/gateserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_main.h
executable file
·102 lines (82 loc) · 2.37 KB
/
test_main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* test_main.h
*
* Created on: 2011-12-12
* Author: luocj
*/
#ifndef TEST_MAIN_H_
#define TEST_MAIN_H_
#include "def/server_namespace.h"
#include "frame_typedef.h"
#include "frame_protocolhead.h"
#include "public_typedef.h"
#include "hallserver_message_define.h"
FRAME_GATESERVER_NAMESPACE_BEGIN
static uint8_t g_messageHead[4096] = {0};
static uint8_t g_messageBody[65535*10] = {0};
class CTestMain
{
public:
CTestMain();
virtual ~CTestMain();
public:
//²âÊÔÇëÇó´¦Àí
static void OnTestRequest()
{
printf("Enter msgid(hex):\n");
uint32_t command = 0;
scanf("%x", &command);
switch(command)
{
case MSGID_HSTA_ONLINE_NOTI:
OnlineMessageRequest(command);
break;
case MSGID_HSTA_OFFLINE_NOTI:
OfflineMessageRequest(command);
break;
default:
break;
}
}
static void OfflineMessageRequest(uint32_t msgid)
{
printf("Enter roleid:");
RoleID nRoleID = 0;
scanf("%d", &nRoleID);
MessageHeadSS *pMessageHead = new(g_messageHead)MessageHeadSS;
GenerateMessageHead(msgid, nRoleID, enmInvalidRoomID, *pMessageHead);
COfflineNoti *pMessageBody = new(g_messageBody)COfflineNoti;
pMessageBody->nRoleID = nRoleID;
g_Frame.PushCommand(pMessageHead,pMessageBody);
}
static void OnlineMessageRequest(uint32_t msgid)
{
printf("Enter roleid:");
RoleID nRoleID = 0;
scanf("%d", &nRoleID);
MessageHeadSS *pMessageHead = new(g_messageHead)MessageHeadSS;
GenerateMessageHead(msgid, nRoleID, enmInvalidRoomID, *pMessageHead);
COnlineNoti *pMessageBody = new(g_messageBody)COnlineNoti;
pMessageBody->nRoleID = nRoleID;
g_Frame.PushCommand(pMessageHead,pMessageBody);
}
static void GenerateMessageHead(uint32_t nMessageID, RoleID nRoleID,
RoomID nRoomID, MessageHeadSS& stMessageHead)
{
stMessageHead.nMessageID = nMessageID;
stMessageHead.nMessageType = enmMessageType_Request;
stMessageHead.nSourceType = 0;
stMessageHead.nDestType = 0;
stMessageHead.nSourceID = 1;
stMessageHead.nDestID = 1;
stMessageHead.nRoleID = nRoleID;
stMessageHead.nSequence = 0;
stMessageHead.nSessionIndex = enmInvalidSessionIndex;
stMessageHead.nRoomID = nRoomID;
stMessageHead.nTransType = enmTransType_ByKey;
stMessageHead.nHeadSize = 0;
stMessageHead.nTotalSize = 0;
}
};
FRAME_GATESERVER_NAMESPACE_END
#endif /* TEST_MAIN_H_ */