2
3
4
5
21
22
26
27
32 using ThreadInitCallback = std::function<
void(
EventLoop*)>;
44
45
46
47
51
52
56
57
58
62
63
64
68
69
70
73 m_ThreadInitCallback = cb;
77
78
79
82 m_ConnectionCallback.Bind(cb);
86
87
88
91 m_MessageCallback.Bind(cb);
95
96
97
100 m_WriteCompleteCallback.Bind(cb);
104
105
106
107 void Start(
int threadSize)
const;
112
113
114
115
119
120
121
125
126
127
133
134
138
139
143
144
148
149
153
154
158
159
163
164
168
169
173
174
#define SPICES_PROFILE_ZONE
Wrapper of readwrite buffer.
ThreadPool of Multiple threading EventLoop.
Wrapper of Poller and wakeup socket to acceptor(SubLoop).
const Version GetVersion() const
Get Http Version.
std::string GetHeader(const std::string &name) const
Get a Header from this HttpRequest.
HttpResponse(bool close)
Constructor Function.
void AppendToBuffer(Buffer *output)
Append this response to Buffer.
bool CloseConnection() const
Get CloseConnection.
HttpServer & operator=(const HttpServer &)=delete
Copy Assignment Operation.
HttpServer(const HttpServer &)=delete
Copy Constructor Function.
void OnRequest(const TcpConnectionPtr &connection, const HttpRequest &request)
HttpCallback m_HttpCallback
virtual ~HttpServer()=default
Destructor Function.
void OnConnection(const TcpConnectionPtr &connection)
HttpServer(const InetAddress &listenAddress, int idleSeconds, TcpServer::Option option=TcpServer::Option::NoReusePort)
Constructor Function.
void Start(int threadSize) const
Start ThreadPool and call listen on acceptor.
WeakConnectionList m_ConnectionList
void OnMessage(const TcpConnectionPtr &connection, Buffer *buf)
This class is Wrapper of current socket address.
Combine of Socket Connection data.
void SetThreadInitCallback(const ThreadInitCallback &cb)
Set Thread initialize Call back.
void AddMessageCallback(const DelegateMessageCallback::Agent &cb)
Add Message Call back.
void Start(int threadSize) const
Start ThreadPool and call listen on acceptor.
std::shared_ptr< EventLoopThreadPool > m_ThreadPool
ThreadPool.
void NewConnection(SOCKET socketFd, const InetAddress &peerAddress)
Handle New Connection to Acceptor.
void RemoveConnectionInLoop(const TcpConnectionPtr &connection)
Remove a TcpConnection InLoop.
TcpServer(const TcpServer &)=delete
Copy Constructor Function.
ConnectionMap m_Connections
All TcpConnections.
DelegateWriteCompleteCallback m_WriteCompleteCallback
WriteCompleteCallback.
void RemoveConnection(const TcpConnectionPtr &connection)
Remove a TcpConnection.
TcpServer(const InetAddress &listenAddress, Option option=Option::NoReusePort)
Constructor Function.
TcpServer & operator=(const TcpServer &)=delete
Copy Assignment Operation.
ThreadInitCallback m_ThreadInitCallback
ThreadInitCallback.
std::unique_ptr< Acceptor > m_Acceptor
Acceptor.
std::string m_IpPort
TcpServer Ip and Port.
void AddConnectionCallback(const DelegateConnectionCallback::Agent &cb)
Add Connection Call back.
virtual ~TcpServer()
Destructor Function.
DelegateConnectionCallback m_ConnectionCallback
ConnectionCallback.
int m_NextConnectedId
Next Connection id.
DelegateMessageCallback m_MessageCallback
MessageCallback.
void AddWriteCompleteCallback(const DelegateWriteCompleteCallback::Agent &cb)
Add WriteComplete Call back.