2023-07-21 16:17:01 +08:00
|
|
|
|
#ifndef LISTENER_H
|
|
|
|
|
#define LISTENER_H
|
|
|
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
#include <boost/beast.hpp>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
class Listener : public std::enable_shared_from_this<Listener> {
|
|
|
|
|
public:
|
2024-01-24 23:19:53 +08:00
|
|
|
|
Listener(boost::asio::io_context &ioc, boost::asio::ip::tcp::endpoint endpoint);
|
2023-07-21 16:17:01 +08:00
|
|
|
|
|
|
|
|
|
// Start accepting incoming connections
|
|
|
|
|
void startAccept();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void fail(boost::beast::error_code ec, char const *what);
|
|
|
|
|
void onAccept(boost::beast::error_code ec, std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
boost::asio::io_context &m_ioContext;
|
|
|
|
|
boost::asio::ip::tcp::acceptor m_acceptor;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // LISTENER_H
|