Debian Codegraph @

LspCpp/include/LibLsp/JsonRpc/TcpServer.h

raw
1 #pragma once
2
3 #include <string>
4 #include "RemoteEndPoint.h"
5
6 namespace lsp
7 {
8 class Log;
9 }
10 namespace lsp
11 {
12 /// The top-level class of the HTTP server.
13 class TcpServer
14 {
15 public:
16 TcpServer(TcpServer const&) = delete;
17 TcpServer& operator=(TcpServer const&) = delete;
18 ~TcpServer();
19 /// Construct the server to listen on the specified TCP address and port, and
20 /// serve up files from the given directory.
21 explicit TcpServer(
22 std::string const& address, std::string const& port, std::shared_ptr<MessageJsonHandler> json_handler,
23 std::shared_ptr<Endpoint> localEndPoint, lsp::Log&, uint32_t _max_workers = 2
24 );
25
26 /// Run the server's io_context loop.
27 void run();
28 void stop();
29
30 RemoteEndPoint point;
31
32 private:
33 struct Data;
34 /// Perform an asynchronous accept operation.
35 void do_accept();
36
37 /// Wait for a request to stop the server.
38 void do_stop();
39 Data* d_ptr = nullptr;
40 };
41 } // namespace lsp