33 lines
No EOL
889 B
C++
33 lines
No EOL
889 B
C++
#ifndef TCP_CONNECTION_HPP
|
|
#define TCP_CONNECTION_HPP
|
|
|
|
#include <boost/system/detail/error_code.hpp>
|
|
#include <memory>
|
|
#include <boost/asio.hpp>
|
|
#include "request_parser.hpp"
|
|
#include "response_handler.hpp"
|
|
|
|
using namespace boost;
|
|
using namespace std;
|
|
|
|
class tcp_connection : public std::enable_shared_from_this<tcp_connection> {
|
|
public:
|
|
typedef std::shared_ptr<tcp_connection> pointer;
|
|
|
|
static pointer create(asio::io_context& io_context);
|
|
asio::ip::tcp::socket& socket();
|
|
void handle();
|
|
|
|
private:
|
|
asio::ip::tcp::socket socket_;
|
|
asio::streambuf buffer_;
|
|
request_parser request_parser_;
|
|
response_handler response_handler_;
|
|
|
|
explicit tcp_connection(asio::io_context& io_context);
|
|
|
|
void handle_read(const system::error_code& error, size_t bytes_transferred);
|
|
void handle_write(const system::error_code& error, size_t bytes_transferred);
|
|
};
|
|
|
|
#endif |