#pragma once #include #define PACKET_HEADERSIZE (sizeof(int) * 3 + sizeof(SHORT) * 4) class AFX_EXT_CLASS CNetPacket { public: CNetPacket(); CNetPacket(const CNetPacket* rhs); virtual ~CNetPacket(); ////////////////////////////////////////////////////////////////////////// // Packet Header void SetVersion(SHORT sNetworkCode, SHORT sVersion); void SetPacketCode(int nCode) { m_nPacketCode = nCode; } void SetModuleNo(int nModuleNo) { m_nModuleNo = nModuleNo; } int Read_PacketHeader(WSABUF* pWsaBuf); int Read_PacketBody(char* pBuf); // º¯¼ö¿¡ Á¢±Ù int GetSize() const { return m_nSize; } SHORT GetNetworkCode() const { return m_sNetworkCode; } SHORT GetVersion() const { return m_sVersion; } int GetPacketCode() const { return m_nPacketCode; } int GetResult() const { return m_sResult; } int GetPacketIndex() const { return m_sPacketIndex; } int GetModuleNo() const { return m_nModuleNo; } ////////////////////////////////////////////////////////////////////////// // Packet Body void ResetValues(); BOOL SetShort(short sValue); BOOL SetInt(int nValue); BOOL SetDouble(double dValue); BOOL SetString(const CString& strString); BOOL SetBuffer(int nSize, const char* pBuffer); int GetShortCount() { return m_nShortCount; } int GetIntCount() { return m_nIntCount; } int GetDoubleCount() { return m_nDoubleCount; } int GetStringCount() { return m_nStringCount; } int GetBufferSize() { return m_nBufferSize; } short GetShort(int nIdx) const; int GetInt(int nIdx) const; double GetDouble(int nIdx) const; CString GetString(int nIdx) const; const char* GetBuffer() const; ////////////////////////////////////////////////////////////////////////// // °ü¸® ÇÔ¼öµé void UnlockPacket() { m_bUsing = FALSE; } BOOL IsUsing() const { return m_bUsing; } void LockPacket() { m_bUsing = TRUE; } protected: BOOL m_bUsing; ////////////////////////////////////////////////////////////////////////// // Packet Header ºÎºÐ int m_nSize; // Size¸¦ Æ÷ÇÔÇÑ Àüü ÆÐŶ Å©±â 4 bytes SHORT m_sNetworkCode; // Program Code * 10 + Network Code 2 bytes SHORT m_sVersion; // Network Module Version 2 bytes int m_nPacketCode; // Packet Code 4 bytes SHORT m_sPacketIndex; // ¿©·¯ PacketÀÏ ¶§ÀÇ Index 2 bytes SHORT m_sResult; // Result - ´Ü¼ø Ack µîÀ» À§ÇÑ ¿¹¾à°ø°£ 2 bytes int m_nModuleNo; // Module Number 4 bytes SHORT m_sSetNetworkCode; // Program Code * 10 + Network Code 2 bytes SHORT m_sSetVersion; // Network Module Version 2 bytes ////////////////////////////////////////////////////////////////////////// // Packet Body ºÎºÐ int m_nShortCount; int m_nShortArraySize; short* m_psShort; int m_nIntCount; int m_nIntArraySize; int* m_pnInt; int m_nDoubleCount; int m_nDoubleArraySize; double* m_pdDouble; int m_nStringCount; int m_nStringArraySize; CString* m_pstrString; int m_nBufferSize; char* m_pBuffer; };