muduo测试框架回调函数
This commit is contained in:
		
							parent
							
								
									b6f13379ad
								
							
						
					
					
						commit
						1e49c92b6c
					
				| @ -12,9 +12,11 @@ epoll+线程池 | ||||
| #include <muduo/net/TcpServer.h> | ||||
| #include <muduo/net/EventLoop.h> | ||||
| #include <iostream> | ||||
| #include <functional> | ||||
| using namespace std; | ||||
| using namespace muduo; | ||||
| using namespace muduo::net; | ||||
| using namespace placeholders; | ||||
| 
 | ||||
| class ChatServer{ | ||||
| public: | ||||
| @ -23,10 +25,23 @@ public: | ||||
|             const string& nameArg) | ||||
|         :_server(loop,listenAddr,nameArg),_loop(loop) | ||||
|     { | ||||
| 
 | ||||
|         //给服务器注册用户连接的创建和断开回调
 | ||||
|         _server.setConnectionCallback(std::bind(&ChatServer::onConnection, this, _1)); | ||||
|         //给服务器注册用户读写事件的回调
 | ||||
|         //_server.setMessageCallback();
 | ||||
|     } | ||||
| 
 | ||||
| private: | ||||
|     void onConnection(const TcpConnectionPtr&) | ||||
|     {   | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|      void Message(const MessageCallback& cb) | ||||
|     { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     TcpServer _server; | ||||
|     EventLoop* _loop; | ||||
| }; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user