2022-09-20 13:37:06 +00:00
|
|
|
|
/*
|
|
|
|
|
* connection.hpp
|
|
|
|
|
*
|
|
|
|
|
* Created on: 20 сент. 2022 г.
|
|
|
|
|
* Author: alexander
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
namespace azh
|
|
|
|
|
{
|
|
|
|
|
using boost::asio::ip::tcp;
|
2022-09-21 06:57:37 +00:00
|
|
|
|
namespace io = boost::asio;
|
2022-09-20 13:37:06 +00:00
|
|
|
|
|
|
|
|
|
class Connection : public std::enable_shared_from_this<Connection>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
using pointer = std::shared_ptr<Connection>;
|
|
|
|
|
|
2022-09-21 06:57:37 +00:00
|
|
|
|
static pointer create(io::ip::tcp::socket&& socket);
|
2022-09-20 13:37:06 +00:00
|
|
|
|
tcp::socket& socket();
|
|
|
|
|
void start();
|
|
|
|
|
private:
|
|
|
|
|
tcp::socket _socket;
|
|
|
|
|
std::string _message = "Hello, client!\n";
|
|
|
|
|
private:
|
2022-09-21 06:57:37 +00:00
|
|
|
|
explicit Connection(io::ip::tcp::socket&& socket);
|
2022-09-20 13:37:06 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|