From 5b7333021d7e80e63de69f5e0d2e89b1623fc29d Mon Sep 17 00:00:00 2001
From: Doralitze <doralitze@chaotikum.org>
Date: Wed, 14 Jul 2021 21:16:27 +0200
Subject: [PATCH] add: Document TCP server class

---
 src/net/tcp_server_socket.hpp | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/net/tcp_server_socket.hpp b/src/net/tcp_server_socket.hpp
index c06c898..a56ee7f 100644
--- a/src/net/tcp_server_socket.hpp
+++ b/src/net/tcp_server_socket.hpp
@@ -17,6 +17,14 @@
 
 namespace rmrf::net {
 
+/**
+ * This class awaits incomming TCP connections and submits them to the provided client listener callback.
+ * @class tcp_server_socket
+ * @author doralitze
+ * @date 14/01/21
+ * @file tcp_server_socket.hpp
+ * @brief A TCP server delivering incomming connections to you.
+ */
 class tcp_server_socket : public std::enable_shared_from_this<tcp_server_socket>{
 public:
     typedef std::function<void(tcp_client)> incoming_client_listener_type;
@@ -27,8 +35,30 @@ private:
     std::atomic_uint32_t number_of_connected_clients;
 
 public:
+    /**
+     * This constructor accepts a port to bind to and the client listener that should be called when clients arrive.
+     * This constructor automatically binds to all avaliable IPv6 interfaces on the specified port.
+     * @brief Construct a TCP server that listens on all interfaces
+     * @param port The port to bind to
+     * @param client_listener_ The client listener to call when a client arrives.
+     */
     tcp_server_socket(const uint16_t port, incoming_client_listener_type client_listener_);
+
+    /**
+     * This constructor accepts an interface description to bind to and the client listener that should be called when clients arrive.
+     * @brief Construct a TCP server that listens on the specified interface
+     * @param socket_identifier The socket to bind to
+     * @param port The port to bind to
+     * @param client_listener_ The client listener to call when a client arrives.
+     */
     tcp_server_socket(const socketaddr& socket_identifier, incoming_client_listener_type client_listener_);
+
+    /**
+     * This method provides you with the current number of connected clients. When a client
+     * disconnects this number will be reduced. When a new client arrives this number will be incremented.
+     * @brief Get the current number of connected clients.
+     * @return  The number of connected clients
+     */
     int get_number_of_connected_clients() const;
 
 private:
-- 
GitLab