]> git.localhorst.tv Git - blank.git/blob - src/shared/CommandService.hpp
add TCP based CLI
[blank.git] / src / shared / CommandService.hpp
1 #ifndef BLANK_SHARED_COMMANDSERVICE_HPP_
2 #define BLANK_SHARED_COMMANDSERVICE_HPP_
3
4 #include "../net/tcp.hpp"
5
6
7 namespace blank {
8
9 class CLI;
10
11 class CommandService
12 : public tcp::IOHandler {
13
14 public:
15         CommandService(CLI &, unsigned short port);
16         ~CommandService();
17
18 public:
19         /// wait on incoming data for at most timeout ms
20         void Wait(int timeout) noexcept;
21         /// true if at least one connected socket can read
22         bool Ready() noexcept;
23         /// handle all inbound traffic
24         void Handle();
25         /// send all outbound traffic
26         void Send();
27
28         void OnRecv(tcp::Socket &) override;
29
30 private:
31         CLI &cli;
32         tcp::Pool pool;
33
34 };
35
36 }
37
38 #endif