blob: f96c87b2c172176efe96d944f4a60034f6e85623 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifndef cserver_h__
#define cserver_h__
class IConnectionProcessor
{
public:
virtual ~IConnectionProcessor() {}
virtual void ProcessConnection() = 0;
};
class IConnectionProcessorFactory
{
public:
virtual IConnectionProcessor *Create(CSocket *s) = 0;
};
class CServer
{
private:
SOCKET m_socket;
IConnectionProcessorFactory *m_connectionProcessorFactory;
DWORD ConnectionAcceptThread();
DWORD ConnectionProcessThread(SOCKET s);
static void GlobalConnectionAcceptThread(void *arg);
struct GlobalConnectionProcessThreadArgs
{
CServer *m_server;
SOCKET m_socket;
GlobalConnectionProcessThreadArgs(CServer *server, SOCKET s): m_server(server), m_socket(s) {}
};
static void GlobalConnectionProcessThread(void *arg);
public:
void Start(int port, IConnectionProcessorFactory *connectionProcessorFactory, bool background);
void Stop();
};
#endif // cserver_h__
|