SDC C-Project CF Review 프로그램
LYW
2021-09-27 b9b6752e83c701cc67241923d2b74dc3a963d243
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
#pragma once
 
#ifndef _HMNETWORK
#include "IOCPController.h"
#include "NetPacket.h"
#define _HMNETWORK
#endif
 
class AFX_EXT_CLASS CNetJoiner
{
public:
    CNetJoiner()
    {
        m_pCtx                = NULL;
        Reset();
    }
    virtual ~CNetJoiner()
    {
        Reset();
    }
    
    void                    Reset()
    {
        m_nModuleNo            = -1;
        if (m_pCtx)
            m_pCtx->Reset();
        m_pCtx                = NULL;
        m_ulIP                = -1;
 
        m_bUseHeartbeat        = FALSE;
        m_dwRecvHeartbeat    = 0;
    }
 
    WSABUF*                    GetSendBuffer()                { return m_pCtx ? m_pCtx->sendContext->GetBuffer() : NULL; }
    pPerSocketContext        GetSocketContext()            { return m_pCtx; }
    ULONG                    GetClientIP()                        { return m_ulIP; }
    int                        GetModuleNo()                { return m_nModuleNo; }
    
    void                    SetSocketContext(pPerSocketContext pCtx)    { m_pCtx = pCtx; }
    void                    SetClientIP(ULONG ulIP)        { m_ulIP = ulIP; }
    void                    SetModuleNo(int nModuleNo, BOOL bUseHeartbeat)
    {
        m_nModuleNo = nModuleNo;
        m_bUseHeartbeat = bUseHeartbeat;
    }
    void                    SetUseHeartbeat(BOOL bUse)    { m_bUseHeartbeat = bUse; }
    void                    SetRecvHeartbeat()            { m_dwRecvHeartbeat = GetTickCount(); }
    DWORD                    GetRecvHeartbeat()            { return m_bUseHeartbeat ? m_dwRecvHeartbeat : 0; }
 
protected:
    BOOL                    m_bUseHeartbeat;
    DWORD                    m_dwRecvHeartbeat;
 
    int                        m_nModuleNo;
    pPerSocketContext        m_pCtx;
    ULONG                    m_ulIP;
};