| | |
| | | #ifndef TCP_SERVER_795VXR94 |
| | | #define TCP_SERVER_795VXR94 |
| | | |
| | | #include "bh_util.h" |
| | | #include "io_service.h" |
| | | #include "tcp_common.h" |
| | | #include <thread> |
| | | |
| | | class TcpServer |
| | | class NodeCenter; |
| | | class TcpServer : public IoService |
| | | { |
| | | public: |
| | | explicit TcpServer(int port); |
| | | typedef std::shared_ptr<Synced<NodeCenter>> CenterPtr; |
| | | TcpServer(int port, CenterPtr pscenter); |
| | | ~TcpServer(); |
| | | bool Start(); |
| | | void Stop(); |
| | | |
| | | private: |
| | | virtual void OnStop(); |
| | | void Accept(); |
| | | std::thread worker_; |
| | | std::atomic<bool> run_; |
| | | boost::asio::io_context io_; |
| | | tcp::acceptor listener_; |
| | | CenterPtr pscenter_; |
| | | }; |
| | | |
| | | #endif // end of include guard: TCP_SERVER_795VXR94 |