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

模拟服务器

开发平台:

C/C++

  1. /********************************************************************
  2. created: 2003/05/31
  3. file base: Intercessor
  4. file ext: h
  5. author: liupeng
  6. purpose:
  7. *********************************************************************/
  8. #ifndef __INCLUDE_INTERCESSOR_H__
  9. #define __INCLUDE_INTERCESSOR_H__
  10. #include "IPlayer.h"
  11. #include "IGServer.h"
  12. #include "GameServer.h"
  13. #include "GamePlayer.h"
  14. #include "msg_define.h"
  15. #include "IClient.h"
  16. #include "RainbowInterface.h"
  17. #include "IServer.h"
  18. #include "HeavenInterface.h"
  19. #include "Library.h"
  20. #include "Event.h"
  21. #include "Network.h"
  22. #include <map>
  23. #include <list>
  24. class CIntercessor
  25. {
  26. public:
  27. explicit CIntercessor( unsigned long lnMaxPlayerCount, CNetwork &theNetworkConfig );
  28. virtual ~CIntercessor();
  29. bool Create( HWND hwndViewer );
  30. void Destroy();
  31. size_t GetGameServerCount();
  32. const char *GetGameServerInfo( const unsigned long &ulnID );
  33. /*
  34.  * Callback function for network
  35.  */
  36. // static void __stdcall AccountEventNotify( LPVOID lpParam, 
  37. // const unsigned long &ulnEventType );
  38. static void __stdcall DBRoleEventNotify( LPVOID lpParam, 
  39. const unsigned long &ulnEventType );
  40. static void __stdcall PlayerEventNotify( LPVOID lpParam,
  41. const unsigned long &ulnID,
  42. const unsigned long &ulnEventType );
  43. protected:
  44. HWND m_hwndViewer;
  45. /*
  46.  * Network
  47.  */
  48. bool StartupNetwork();
  49. void CleanNetwork();
  50. typedef HRESULT ( __stdcall * pfnCreateServerInterface )( REFIID riid, void **ppv );
  51. typedef HRESULT ( __stdcall * pfnCreateClientInterface )( REFIID riid, void **ppv );
  52. static OnlineGameLib::Win32::CLibrary m_theHeavenLib;
  53. static OnlineGameLib::Win32::CLibrary m_theRainbowLib;
  54. // IClient *m_pAccSvrClient;
  55. IClient *m_pDBRoleClient;
  56. IServer *m_pGameSvrServer;
  57. IServer *m_pPlayerServer;
  58. /*
  59.  * Helper function
  60.  */
  61. void _PlayerEventNotify( const unsigned long &ulnID,
  62. const unsigned long &ulnEventType );
  63. // void _AccountEventNotify( const unsigned long &ulnEventType );
  64. void _DBRoleEventNotify( const unsigned long &ulnEventType );
  65. /*
  66.  * Listen and accept data from network
  67.  */
  68. HANDLE m_hWorkingThread;
  69. HANDLE m_hHelperThread;
  70. static DWORD WINAPI WorkingThreadFunction( void *pV );
  71. int Working();
  72. static DWORD WINAPI HelperThreadFunction( void *pV );
  73. int Helper();
  74. bool AnalyzePlayerRequire( size_t index, const void *pData, size_t datalength );
  75. private:
  76. OnlineGameLib::Win32::CEvent m_hQuitEvent;
  77. OnlineGameLib::Win32::CEvent m_hStartupWoringThreadEvent;
  78. OnlineGameLib::Win32::CEvent m_hStartupHelperThreadEvent;
  79. CNetwork &m_theNetworkConfig;
  80. /*
  81.  * Player information
  82.  */
  83. const unsigned long m_lnMaxPlayerCount;
  84. OnlineGameLib::Win32::CCriticalSection m_csPlayerAction;
  85. typedef std::map< size_t, IPlayer * > PLAYER_MAP;
  86. PLAYER_MAP m_thePlayers;
  87. /*
  88.  * Loader balance information
  89.  */
  90. };
  91. #endif // __INCLUDE_INTERCESSOR_H__