123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #ifndef IOMANAGER_HPP
- #define IOMANAGER_HPP
- #include "global.hpp"
- #include <string>
- #include <boost/asio.hpp>
- #include <json/json.h>
- #define BLOCKSIZE 8
- using boost::asio::ip::tcp;
- class IoManager {
- protected:
- boost::asio::io_service ios;
- tcp::socket *tcpsock;
- boost::system::error_code errcode;
- std::string ipstring;
- int port;
- std::string jsonerror;
- Json::CharReaderBuilder rbuilder;
- Json::CharReader* reader;
- Json::StreamWriterBuilder wbuilder;
- bool sendJson(Json::Value root);
- bool receiveJson(boost::asio::streambuf &recvbuf);
- bool parseJson(Json::Value *root, boost::asio::streambuf &recvbuf);
- public:
- // Basic constructor
- IoManager(char *ipcstring);
- // destructor to clean up all generic stuff
- ~IoManager();
- // enters loop to handle further interaction based on derived class
- virtual void run() = 0;
- // tries to establish connection, returns false on error
- bool connect();
- };
- #endif
|