-
Notifications
You must be signed in to change notification settings - Fork 2
/
net_thread.cpp
50 lines (41 loc) · 1.41 KB
/
net_thread.cpp
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
#include "net_thread.h"
#include <string.h>
#include "protocol.h"
#include "handler.h"
#include "tcp_handler.h"
#include "listen_handler.h"
namespace NSQTOOL
{
CNetThread::CNetThread(int32_t iThreadType, int32_t iThreadId)
:CEventThread(iThreadType, iThreadId)
{
}
void CNetThread::OnStaticRead(struct bufferevent *pBufevt, void *arg)
{
CTcpHandler *pHandler = (CTcpHandler *)(arg);
pHandler->TcpRead();
}
void CNetThread::OnStaticWrite(struct bufferevent *pBufevt, void *arg)
{
CTcpHandler *pHandler = (CTcpHandler *)(arg);
pHandler->TcpWrite();
}
void CNetThread::OnStaticError(struct bufferevent *pBufevt, short iTemp, void *arg)
{
CTcpHandler *pHandler = (CTcpHandler *)(arg);
pHandler->TcpDelete(iTemp);
}
//////////////////////////////////////////////////////////
// CListenThread
/////////////////////////////////////////////////////////
CListenThread::CListenThread(int32_t iThreadType, int32_t iThreadId)
:CEventThread(iThreadType, iThreadId)
{
}
void CListenThread::OnStaticRead(struct evconnlistener *pListener, evutil_socket_t iAcceptHandler,
struct sockaddr *pAddr, int socklen, void *pArg)
{
CListenHandler *pHandler = (CListenHandler *) (pArg);
pHandler->TcpListenAccept(iAcceptHandler, pAddr, socklen);
}
};