OSDN Git Service

classify : fix DB id undefined.
[rec10/rec10-git.git] / b25-remote / CasServer.h
1 // CasServer.h: CCasServer クラスのインターフェイス
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #pragma once
6
7
8 #include <map>
9 #include "CasClient.h"
10 #include "TsUtilClass.h"
11 #include "SmartSock.h"
12
13
14 using std::map;
15
16
17 class CCasServer : protected CCasClient::ICasClientHandler
18 {
19 public:
20         class ICasServerHandler
21         {
22         public:
23                 virtual void OnCasServerEvent(CCasServer *pCasServer, const WORD wEventID) = 0;
24         };
25
26         enum
27         {
28                 CSEI_CONNECTED,         // クライアント接続
29                 CSEI_DISCONNECTED,      // クライアント切断
30         };
31
32         CCasServer(void);
33         CCasServer(ICasServerHandler *pEventHandler);
34         ~CCasServer(void);
35
36         const BOOL OpenServer(const WORD wServerPort);
37         void CloseServer(void);
38         
39         const DWORD GetClientNum(void) const;
40
41 protected:
42         virtual void OnCasClientEvent(CCasClient *pClient, const DWORD dwEventID, PVOID pParam);
43
44         void ServerThread(void);
45         static void* ServerThreadRaw(LPVOID pParam);
46
47         ICasServerHandler *m_pEventHandler;
48
49         CSmartSock m_pSocket;
50         pthread_t m_hServerThread;
51
52         typedef map<CCasClient *, CCasClient *> ClientList;
53         ClientList m_ClientList;
54         
55         CCriticalLock m_Lock;
56 };