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

模拟服务器

开发平台:

C/C++

  1. /********************************************************************
  2. created: 2003/03/04
  3. file base: GameServer
  4. file ext: h
  5. author: liupeng
  6. purpose:
  7. *********************************************************************/
  8. #ifndef __INCLUDE_ONLINEGAME_GAMESERVER_H__
  9. #define __INCLUDE_ONLINEGAME_GAMESERVER_H__
  10. #if defined (_MSC_VER) && (_MSC_VER >= 1020)
  11. #pragma once
  12. #endif
  13. //[ Include in ...IPCPServer
  14. #include "IOCPServerSocketServer.h"
  15. #include "IOCPServertstring.h"
  16. //]
  17. /*
  18.  * Classes defined in other files...
  19.  */
  20. namespace OnlineGameLib {
  21. namespace Win32 {
  22. //[ Include in ...IPCPServer
  23. class CIOCompletionPort;
  24. //]
  25. } // End of namespace OnlineGameLib
  26. } // End of namespace Win32
  27. class CGameServer : public OnlineGameLib::Win32::CSocketServer
  28. {
  29. public:
  30. CGameServer(
  31. unsigned long addressToListenOn,
  32. unsigned short portToListenOn,
  33. size_t maxFreeSockets,
  34. size_t maxFreeBuffers,
  35. size_t bufferSize = 1024,
  36. size_t numThreads = 0);
  37. CGameServer(
  38. size_t maxFreeSockets,
  39. size_t maxFreeBuffers,
  40. size_t bufferSize = 1024,
  41. size_t numThreads = 0);
  42. virtual ~CGameServer();
  43. private:
  44. virtual WorkerThread *CreateWorkerThread(
  45. OnlineGameLib::Win32::CIOCompletionPort &iocp);
  46. virtual SOCKET CreateListeningSocket(
  47. unsigned long address,
  48. unsigned short port);
  49. virtual void OnConnectionEstablished(
  50. OnlineGameLib::Win32::CSocketServer::Socket *pSocket,
  51. OnlineGameLib::Win32::CIOBuffer *pAddress);
  52. virtual void OnConnectionClosed( 
  53. OnlineGameLib::Win32::CSocketServer::Socket *pSocket );
  54. virtual void OnError( const OnlineGameLib::Win32::_tstring &message );
  55. virtual void PreWrite( 
  56. OnlineGameLib::Win32::CSocketServer::Socket *pSocket, 
  57. OnlineGameLib::Win32::CIOBuffer *pBuffer, 
  58. const char *pData, 
  59. size_t dataLength );
  60. /*
  61.  * No copies do not implement
  62.  */
  63. CGameServer( const CGameServer &rhs );
  64. CGameServer &operator=( const CGameServer &rhs );
  65. };
  66. #endif //__INCLUDE_ONLINEGAME_GAMESERVER_H__