From a736abb4e3668771f248e7400a093cb40b5313b7 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Mon, 29 Aug 2016 13:29:30 +0200 Subject: Adds the Acceptor and Client class. The acceptor combines the endpoint and acceptor to reduce clutter in NetworkHandler class. The client will handle the connection for the network handler for every separate client. The networkhander now has a std::list of Client, to keep track and ownership of all the Clients. --- network-handler/acceptor.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 network-handler/acceptor.hpp (limited to 'network-handler/acceptor.hpp') diff --git a/network-handler/acceptor.hpp b/network-handler/acceptor.hpp new file mode 100644 index 0000000..7d8e0a2 --- /dev/null +++ b/network-handler/acceptor.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include + +#include + +class Acceptor{ + boost::asio::ip::tcp::acceptor acceptor; + boost::asio::ip::tcp::endpoint endpoint; + +public: + Acceptor(boost::asio::io_service& io_service, boost::asio::ip::address address, uint16_t port); + + boost::asio::ip::address get_address() { return endpoint.address(); } + + void bind_v6_and_v4_any(std::function accept_handler); + void setup_listen_socket(std::function accept_handler); +}; -- cgit v1.2.3-70-g09d2