26 lines
733 B
C++
26 lines
733 B
C++
#ifndef __LISTENER_H__
|
|
#define __LISTENER_H__
|
|
|
|
#include <boost/asio/io_context.hpp>
|
|
#include <boost/asio/ip/tcp.hpp>
|
|
#include <boost/beast/core/error.hpp>
|
|
#include <memory>
|
|
|
|
class SharedState;
|
|
|
|
class Listener : public std::enable_shared_from_this<Listener> {
|
|
public:
|
|
Listener(boost::asio::io_context &ioContext, const boost::asio::ip::tcp::endpoint &endpoint,
|
|
const std::shared_ptr<SharedState> &state);
|
|
void startAccept();
|
|
|
|
protected:
|
|
void onAccept(boost::beast::error_code errorCode, std::shared_ptr<boost::asio::ip::tcp::socket> socket);
|
|
|
|
private:
|
|
boost::asio::io_context &m_ioContext;
|
|
boost::asio::ip::tcp::acceptor m_acceptor;
|
|
std::weak_ptr<SharedState> m_state;
|
|
};
|
|
|
|
#endif // __LISTENER_H__
|