-
Notifications
You must be signed in to change notification settings - Fork 42
/
SocketHandler.h
51 lines (34 loc) · 1012 Bytes
/
SocketHandler.h
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
43
44
45
46
47
48
49
50
#ifndef INC_SEXT_SOCKETHANDLER_H
#define INC_SEXT_SOCKETHANDLER_H
#include <deque>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include "Socket.h"
struct SocketWrapper {
SocketWrapper(void* socket, SM_SocketType socketType) : socket(socket), socketType(socketType) {}
~SocketWrapper();
void* socket;
SM_SocketType socketType;
};
class SocketHandler {
public:
SocketHandler();
~SocketHandler();
void Shutdown();
SocketWrapper* GetSocketWrapper(const void* socket);
template <class SocketType> Socket<SocketType>* CreateSocket(SM_SocketType st);
void DestroySocket(SocketWrapper* sw);
void StartProcessing();
void StopProcessing();
//friend class Socket;
boost::asio::io_service* ioService;
private:
std::deque<SocketWrapper*> socketList;
boost::mutex socketListMutex;
boost::asio::io_service::work* ioServiceWork;
boost::thread* ioServiceProcessingThread;
bool ioServiceProcessingThreadInitialized;
void RunIoService();
};
extern SocketHandler socketHandler;
#endif