26 lines
684 B
C++
26 lines
684 B
C++
#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:
|
|
Listener(boost::asio::io_context &ioc, boost::asio::ip::tcp::endpoint endpoint);
|
|
|
|
// 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
|