1 #ifndef BLANK_SHARED_COMMANDBUFFER_HPP_
2 #define BLANK_SHARED_COMMANDBUFFER_HPP_
4 #include "CLIContext.hpp"
5 #include "../net/tcp.hpp"
12 /// Turns a tcp stream into commands and writes their
13 /// output back to the stream.
14 /// Instances delete themselves when OnRemove(tcp::Socket &)
15 /// is called, so make sure it was either allocated with new
16 /// and isn't dereferenced after removal or OnRemove is never
20 , public tcp::IOHandler {
23 explicit CommandBuffer(CLI &);
24 ~CommandBuffer() override;
26 // CLIContext implementation
27 void Error(const std::string &) override;
28 void Message(const std::string &) override;
29 void Broadcast(const std::string &) override;
31 /// IOHandler implementation
32 void OnSend(tcp::Socket &) override;
33 void OnRecv(tcp::Socket &) override;
34 void OnRemove(tcp::Socket &) noexcept override;
38 std::string write_buffer;
39 std::string read_buffer;