-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLibEvent.h
31 lines (27 loc) · 922 Bytes
/
LibEvent.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
#pragma once
#include "CLibEventData.h"
#include "UserCallBack.h"
#include <map>
class CLibEvent
{
public:
CLibEvent(void);
~CLibEvent(void);
private:
//µ±Ç°·þÎñÆ÷¶ÔÏó
Server m_Server;
public:
bool StartServer(int port, short workernum, unsigned int connnum, int read_timeout, int write_timeout,
int inbuffmax,int outbuffmax,ITcpPacketNotify* notify);
void StopServer();
bool SendPacket(int fd, const char* packet, int packetlen);
private:
static void DoAccept(struct evconnlistener *listener, evutil_socket_t fd,struct sockaddr *sa, int socklen, void *user_data);
static void DoError(struct bufferevent *bev, short error, void *ctx);
static void CloseConn(Conn *pConn);
static void DoRead(struct bufferevent *bev, void *ctx);
static void ThreadServer(void* lPVOID);
static void ThreadWorkers(void* lPVOID);
ITcpPacketNotify * m_notify;
std::recursive_mutex m_cs;
};