From 3578bd5b5cc715fa0843936a07a756a049ecc624 Mon Sep 17 00:00:00 2001 From: iherman- <200969603+iherman-p@users.noreply.github.com> Date: Tue, 12 May 2026 20:02:32 +0200 Subject: [PATCH] Made the commands_ map be a Server attribute --- Server/Server.cpp | 36 +++++++++++++++++++----------------- Server/Server.hpp | 4 +++- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Server/Server.cpp b/Server/Server.cpp index aa61cb6..5f73f43 100644 --- a/Server/Server.cpp +++ b/Server/Server.cpp @@ -6,7 +6,7 @@ /* By: iherman- > command; - std::map commands; - // TEMP - commands["echo"] = &echo; - - std::map::iterator it = commands.find(command); - if (it == commands.end()) + std::map::iterator it = commands_.find(command); + if (it == commands_.end()) { - std::string message = "Error: command not found!"; + std::string message = "Error: command not found!\n"; send(client.getFd(), message.c_str(), message.size(), 0); client.clearBuffer(); return ; } - it->second(client); + it->second(client, args); client.clearBuffer(); } diff --git a/Server/Server.hpp b/Server/Server.hpp index b21fb29..c8cbc88 100644 --- a/Server/Server.hpp +++ b/Server/Server.hpp @@ -6,7 +6,7 @@ /* By: iherman- sockets_; std::map clients_; + std::map commands_; + bool handleClient(User& client); void addClient();