geekbrains_network_programming/lesson_04/connection/connection.hpp

34 lines
665 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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