41 lines
787 B
C++
41 lines
787 B
C++
#ifndef CONNECTION_H
|
|
#define CONNECTION_H
|
|
|
|
#include "Protocol/Protocol.h"
|
|
#include "Util/Util.h"
|
|
#include <asio.hpp>
|
|
#include <string>
|
|
|
|
|
|
namespace MailServer {
|
|
|
|
class Connection
|
|
{
|
|
public:
|
|
Connection(asio::io_service& ioService, const Util::Context& context);
|
|
|
|
asio::ip::tcp::socket& Socket();
|
|
|
|
void Start();
|
|
|
|
private:
|
|
Connection(const Connection&) = delete;
|
|
Connection& operator=(const Connection&) = delete;
|
|
|
|
private:
|
|
void StartRead();
|
|
void HandleRead(const asio::error_code& ec, std::size_t length);
|
|
void StartWrite(const std::string& message);
|
|
void HandleWrite(const asio::error_code& ec);
|
|
|
|
asio::io_service& m_ioService;
|
|
asio::ip::tcp::socket m_socket;
|
|
std::array<char, 1024> m_data;
|
|
|
|
Protocol::Protocol m_protocol;
|
|
};
|
|
|
|
} // namespace MailServer
|
|
|
|
#endif // CONNECTION_H
|