Network.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:2k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /********************************************************************
  2. created: 2003/05/05
  3. file base: Network
  4. file ext: h
  5. author: liupeng
  6. purpose:
  7. *********************************************************************/
  8. #ifndef __INCLUDE_NETWORK_H__
  9. #define __INCLUDE_NETWORK_H__
  10. #pragma once
  11. #include "IClient.h"
  12. #include "RainbowInterface.h"
  13. #include "IServer.h"
  14. #include "HeavenInterface.h"
  15. #include "Library.h"
  16. #include "Buffer.h"
  17. #include "tstring.h"
  18. #include "CriticalSection.h"
  19. class CNetwork
  20. {
  21. public:
  22. CNetwork();
  23. virtual ~CNetwork();
  24. bool Create();
  25. void Destroy();
  26. // IClient *CreateAccSvrClient( const char * const pAddressToConnectServer, 
  27. // unsigned short usPortToConnectServer );
  28. const char *GetAccSvrIP() { return m_sAccSvrIP.c_str(); }
  29. unsigned short GetAccSvrPort() { return m_nAccSvrPort; }
  30. const char *GetRoleSvrIP() { return m_sRoleSvrIP.c_str(); }
  31. void SetRoleSvrIP( const char *pAddress ) { if ( pAddress ) { m_sRoleSvrIP = pAddress; } }
  32. unsigned short GetRoleSvrPort() { return m_nRoleSvrPort; }
  33. void SetRoleSvrPort( unsigned short nRoleSvrPort ) { m_nRoleSvrPort = nRoleSvrPort; }
  34. unsigned short GetClientOpenPort() { return m_nClientOpenPort; }
  35. void SetClientOpenPort( unsigned short nClientOpenPort ) { m_nClientOpenPort = nClientOpenPort; }
  36. unsigned short GetGameSvrOpenPort() { return m_nGameSvrOpenPort; }
  37. void SetGameSvrOpenPort( unsigned short nGameSvrOpenPort ) { m_nGameSvrOpenPort = nGameSvrOpenPort; }
  38. protected:
  39. typedef HRESULT ( __stdcall * pfnCreateServerInterface )( REFIID riid, void **ppv );
  40. typedef HRESULT ( __stdcall * pfnCreateClientInterface )( REFIID riid, void **ppv );
  41. static OnlineGameLib::Win32::CLibrary m_theHeavenLib;
  42. static OnlineGameLib::Win32::CLibrary m_theRainbowLib;
  43. // static void __stdcall AccSvrEventNotify( LPVOID lpParam, const unsigned long &ulnEventType );
  44. // void DistroyAccSvrClient();
  45. private:
  46. /*
  47.  * Account server config
  48.  */
  49. // IClient *m_pAccSvrClient;
  50. OnlineGameLib::Win32::_tstring m_sAccSvrIP;
  51. unsigned short m_nAccSvrPort;
  52. /*
  53.  * Role server config
  54.  */
  55. OnlineGameLib::Win32::_tstring m_sRoleSvrIP;
  56. unsigned short m_nRoleSvrPort;
  57. /*
  58.  * Client config
  59.  */
  60. unsigned short m_nClientOpenPort;
  61. /*
  62.  * Game server config
  63.  */
  64. unsigned short m_nGameSvrOpenPort;
  65. };
  66. #endif // __INCLUDE_NETWORK_H__