#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; };