45 int listen(uint16_t port);
53 bool listenStdio(std::istream& in = std::cin, std::ostream& out = std::cout);
56 int port()
const {
return port_.load(); }
57 bool hasClient()
const {
return hasClient_.load(); }
66 void setGameRoot(std::string root);
67 const std::string&
gameRoot()
const {
return gameRoot_; }
75 void acceptNonBlocking();
76 void readAndDispatch();
77 bool sendLine(
const std::string& json);
78 void handleMessage(
const std::string& json);
80 std::atomic<bool> listening_{
false};
81 std::atomic<bool> hasClient_{
false};
82 std::atomic<int> port_{0};
83 std::atomic<Transport> transport_{Transport::None};
84 std::atomic<bool> stdinClosed_{
false};
86 std::unique_ptr<Poco::Net::ServerSocket> server_;
87 std::unique_ptr<Poco::Net::StreamSocket> client_;
88 std::istream* stdioIn_ =
nullptr;
89 std::ostream* stdioOut_ =
nullptr;
90 std::vector<std::string> stdioQueue_;
91 std::thread stdioReader_;
92 bool joinReader_ =
false;
94 std::string gameRoot_;
95 bool initialized_ =
false;
96 std::string protocolVersion_ =
"2025-06-18";