-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathPackageIOCP.h
62 lines (51 loc) · 1.47 KB
/
PackageIOCP.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
#pragma once
#pragma pack(1)
#define NET_PACKAGE_TITLE 0x55E0
struct NETPackage
{
unsigned int length;
unsigned short title;
};
#pragma pack()
class PackageUserContext
{
public:
PackageUserContext(){
m_lpBufferWriter = OP_NEW<CIOCPBufferWriter>(_FILE_AND_LINE_);
lpPerSocketContext = NULL;
m_nUserID = NULL;
}
virtual ~PackageUserContext(){
OP_DELETE<CIOCPBufferWriter>(m_lpBufferWriter,_FILE_AND_LINE_);
m_lpBufferWriter = NULL;
}
PPER_SOCKET_CONTEXT lpPerSocketContext;
LONGLONG m_nUserID;
CIOCPBufferWriter* m_lpBufferWriter;
};
typedef std::map<LONGLONG,PackageUserContext*> PackageContextMap_t;
class PackageIOCPManager
{
private:
IOCPMutex m_critical;
PackageContextMap_t m_ContextMap;
public:
PackageUserContext* GetContext(LONGLONG nUserID);
VOID AddContext(PPER_SOCKET_CONTEXT lpPerSocketContext);
VOID DelContext(LONGLONG nUserID);
};
class PackageIOCP:
public CBaseIOCPServer
{
public:
PackageIOCP(void);
~PackageIOCP(void);
PackageIOCPManager m_manager;
VOID SendEx(PPER_SOCKET_CONTEXT lpPerSocketContext,CIOCPBuffer* lpBuffer);
VOID SendEx(LONGLONG guid,CIOCPBuffer* lpBuffer);
virtual VOID NotifyNewConnection(PPER_SOCKET_CONTEXT lpPerSocketContext);
virtual VOID NotifyDisconnectedClient(PPER_SOCKET_CONTEXT lpPerSocketContext);
virtual VOID NotifyReceivedPackage(PPER_SOCKET_CONTEXT lpPerSocketContext, CIOCPBuffer* pBuffer);
public:
virtual VOID NotifyReceivedFormatPackage(PPER_SOCKET_CONTEXT lpPerSocketContext, CIOCPBuffer* pBuffer);
};