#ifndef IOMANAGER_HPP #define IOMANAGER_HPP #include "global.hpp" #include #include #include #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