forked from Miaoshuai/netlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.h
49 lines (46 loc) · 1.45 KB
/
server.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
/*======================================================
> File Name: server.h
> Author: MiaoShuai
> E-mail:
> Other :
> Created Time: 2015年12月20日 星期日 15时07分50秒
=======================================================*/
#ifndef SERVER_H_
#define SERVER_H_
#include "base_loop.h"
#include <memory>
#include <string>
#include "callback.h"
namespace netlib
{
class Server
{
public:
Server(std::string ip,int port,int loopNumber);
~Server();
void start(void); //开始运行server
void setConnectionCallback(connectionCallback cb)
{
connectionCallback_ = cb;
}
void setMessageCallback(messageCallback cb)
{
messageCallback_ = cb;
}
void setCloseCallback(closeCallback cb)
{
closeCallback_ = cb;
}
void setWriteCompleteCallback(writeCompleteCallback cb)
{
writeCompleteCallback_ = cb;
}
private:
std::shared_ptr<BaseLoop> baseLoopPtr_; //保存baseLoop的智能指针
connectionCallback connectionCallback_; //连接回调
messageCallback messageCallback_; //消息回调
closeCallback closeCallback_; //关闭回调
writeCompleteCallback writeCompleteCallback_;//写完成回调
};
}
#endif