OSDN Git Service

add dist
[rec10/rec10-git.git] / dist / trunk / b25-remote / CasServer.h
1 // CasServer.h: CCasServer \83N\83\89\83X\82Ì\83C\83\93\83^\81[\83t\83F\83C\83X\r
2 //\r
3 //////////////////////////////////////////////////////////////////////\r
4 \r
5 #pragma once\r
6 \r
7 \r
8 #include <map>\r
9 #include "CasClient.h"\r
10 #include "TsUtilClass.h"\r
11 #include "SmartSock.h"\r
12 \r
13 \r
14 using std::map;\r
15 \r
16 \r
17 class CCasServer : protected CCasClient::ICasClientHandler\r
18 {\r
19 public:\r
20         class ICasServerHandler\r
21         {\r
22         public:\r
23                 virtual void OnCasServerEvent(CCasServer *pCasServer, const WORD wEventID) = 0;\r
24         };\r
25 \r
26         enum\r
27         {\r
28                 CSEI_CONNECTED,         // \83N\83\89\83C\83A\83\93\83g\90Ú\91±\r
29                 CSEI_DISCONNECTED,      // \83N\83\89\83C\83A\83\93\83g\90Ø\92f\r
30         };\r
31 \r
32         CCasServer(void);\r
33         CCasServer(ICasServerHandler *pEventHandler);\r
34         ~CCasServer(void);\r
35 \r
36         const BOOL OpenServer(const WORD wServerPort);\r
37         void CloseServer(void);\r
38         \r
39         const DWORD GetClientNum(void) const;\r
40 \r
41 protected:\r
42         virtual void OnCasClientEvent(CCasClient *pClient, const DWORD dwEventID, PVOID pParam);\r
43 \r
44         void ServerThread(void);\r
45         static void* ServerThreadRaw(LPVOID pParam);\r
46 \r
47         ICasServerHandler *m_pEventHandler;\r
48 \r
49         CSmartSock m_pSocket;\r
50         pthread_t m_hServerThread;
51 \r
52         typedef map<CCasClient *, CCasClient *> ClientList;\r
53         ClientList m_ClientList;\r
54         \r
55         CCriticalLock m_Lock;\r
56 };\r