X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fshared%2FCommandService.hpp;fp=src%2Fshared%2FCommandService.hpp;h=38531edf3cf4e987312048979feacd4bb431cc31;hb=b07f3c123fff221edeffb4864bab7db88d0d1f4d;hp=0000000000000000000000000000000000000000;hpb=20d0a76d2519c71009c3b3babec0df27529f8142;p=blank.git diff --git a/src/shared/CommandService.hpp b/src/shared/CommandService.hpp new file mode 100644 index 0000000..38531ed --- /dev/null +++ b/src/shared/CommandService.hpp @@ -0,0 +1,38 @@ +#ifndef BLANK_SHARED_COMMANDSERVICE_HPP_ +#define BLANK_SHARED_COMMANDSERVICE_HPP_ + +#include "../net/tcp.hpp" + + +namespace blank { + +class CLI; + +class CommandService +: public tcp::IOHandler { + +public: + CommandService(CLI &, unsigned short port); + ~CommandService(); + +public: + /// wait on incoming data for at most timeout ms + void Wait(int timeout) noexcept; + /// true if at least one connected socket can read + bool Ready() noexcept; + /// handle all inbound traffic + void Handle(); + /// send all outbound traffic + void Send(); + + void OnRecv(tcp::Socket &) override; + +private: + CLI &cli; + tcp::Pool pool; + +}; + +} + +#endif