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

模拟服务器

开发平台:

C/C++

  1. #include "GameServerWorkerThread.h"
  2. //[ Include in ...IPCPServer
  3. #include "IOCPServerUtils.h"
  4. #include "IOCPServertstring.h"
  5. #include "IOCPServerException.h"
  6. //]
  7. //[ Include in ...Protocol
  8. #include "ProtocolProtocol.h"
  9. //]
  10. /*
  11.  * Using directives
  12.  */
  13. using OnlineGameLib::Win32::CIOCompletionPort;
  14. using OnlineGameLib::Win32::CIOBuffer;
  15. using OnlineGameLib::Win32::CSocketServer;
  16. using OnlineGameLib::Win32::Output;
  17. using OnlineGameLib::Win32::OutPutInfo;
  18. using OnlineGameLib::Win32::_tstring;
  19. using OnlineGameLib::Win32::CException;
  20. using OnlineGameLib::Win32::ToString;
  21. using OnlineGameLib::Win32::DumpData;
  22. CGameServerWorkerThread::CGameServerWorkerThread(
  23.  CIOCompletionPort &iocp)
  24.    : CSocketServer::WorkerThread(iocp)
  25. {
  26. }
  27. CGameServerWorkerThread::~CGameServerWorkerThread()
  28. {
  29. }
  30. void CGameServerWorkerThread::ReadCompleted(
  31. CSocketServer::Socket *pSocket,
  32. CIOBuffer *pBuffer)
  33. {
  34. try
  35. {
  36. pSocket->Read( pBuffer );
  37. }
  38. catch(const CException &e)
  39. {
  40. Output( _T("ReadCompleted - Exception - ") + e.GetWhere() + _T(" - ") + e.GetMessage() );
  41. pSocket->Shutdown();
  42. }
  43. catch(...)
  44. {
  45. Output( _T("ReadCompleted - Unexpected exception") );
  46. pSocket->Shutdown();
  47. }
  48. }
  49. void CGameServerWorkerThread::OnError( const OnlineGameLib::Win32::_tstring &message )
  50. {
  51. Output( _T("CGameServerWorkerThread::OnError - ") + message );
  52. }