ServerPtr.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef __SERVER_PTR_20190920__
  2. #define __SERVER_PTR_20190920__
  3. #pragma once
  4. #include "HPSocket4C.h"
  5. #include "helper.h"
  6. class CServerPtr
  7. {
  8. CServerPtr(void);
  9. public:
  10. ~CServerPtr(void);
  11. static CServerPtr* GetInstance()
  12. {
  13. if ( m_spThis == NULL )
  14. {
  15. m_spThis = new CServerPtr();
  16. }
  17. return m_spThis;
  18. }
  19. public:
  20. void SetAppState(EnAppState state);
  21. private:
  22. static En_HP_HandleResult __stdcall OnPrepareListen(HP_Server pSender, SOCKET soListen);
  23. static En_HP_HandleResult __stdcall OnAccept(HP_Server pSender, HP_CONNID dwConnID, SOCKET soClient);
  24. static En_HP_HandleResult __stdcall OnSend(HP_Server pSender, HP_CONNID dwConnID, const BYTE* pData, int iLength);
  25. static En_HP_HandleResult __stdcall OnReceive(HP_Server pSender, HP_CONNID dwConnID, const BYTE* pData, int iLength);
  26. static En_HP_HandleResult __stdcall OnClose(HP_Server pSender, HP_CONNID dwConnID, En_HP_SocketOperation enOperation, int iErrorCode);
  27. static En_HP_HandleResult __stdcall OnShutdown(HP_Server pSender);
  28. private:
  29. TPkgInfo* FindPkgInfo(HP_CONNID dwConnID);
  30. void RemovePkgInfo(HP_CONNID dwConnID);
  31. private:
  32. static const USHORT PORT;
  33. static const LPCTSTR ADDRESS;
  34. EnAppState m_enState;
  35. CString m_strAddress;
  36. static CServerPtr* m_spThis;
  37. HP_TcpPackServer m_pServer;
  38. HP_TcpServerListener m_pListener;
  39. public:
  40. static BOOL Start();
  41. static BOOL Stop();
  42. static void Release();
  43. static BOOL Disconnect(IN const DWORD& dwConnId);
  44. public:
  45. // µÇ¼µÇ³ö;
  46. static void Req_Login(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
  47. static void Req_LogOut(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
  48. // ²¿ÃÅ;
  49. static void New_Department(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
  50. static void Del_Department(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
  51. static void Mod_Department(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
  52. static EnHandleResult Ask_Department(IN HP_CONNID dwConnID, IN const BYTE* pReceiveData, IN INT nReceiveLength, IN TheProPackage &thepackage, OUT BYTE*& pSendData, OUT DWORD &dwSendLen);
  53. };
  54. #endif