From 41e56955cd6b205b24bb487dd99dc019b9a1823b Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 13 May 2025 12:06:38 +0200 Subject: [PATCH] feat(core): adding the port management --- include/core/server.hpp | 3 ++- sources/core/server.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/core/server.hpp b/include/core/server.hpp index 7e13b9c..6f050f8 100644 --- a/include/core/server.hpp +++ b/include/core/server.hpp @@ -16,10 +16,11 @@ class Server { private: - int _port; + unsigned short int _port; std::string _password; public: Server(); Server(int port, const std::string &password); ~Server(); + unsigned short int getPort() const; }; diff --git a/sources/core/server.cpp b/sources/core/server.cpp index 62a8052..abb71e6 100644 --- a/sources/core/server.cpp +++ b/sources/core/server.cpp @@ -31,12 +31,21 @@ Server::Server() : _port(0), _password("") { * @note Thanks to check the port / password before give them to the constructor. */ Server::Server(int port, const std::string &password) : _port(port), _password(password) { - std::cout << CLR_GREY << "[INFO] Server constructor called" << CLR_RESET << std::endl; + std::cout << CLR_GREY << "Info: Server constructor called" << CLR_RESET << std::endl; } /** * @brief The default destructor of the Server class. */ Server::~Server() { - std::cout << CLR_GREY << "[INFO] Server destructor called" << CLR_RESET << std::endl; + std::cout << CLR_GREY << "Info: Server destructor called" << CLR_RESET << std::endl; +} + +/** + * @brief The getter of the port. + * + * @return the port of the server + */ +unsigned short int Server::getPort() const { + return this->_port; }