set a nickname, a username, join a channel,

send and receive private messages using your reference client and All the messages sent from one client to a channel have to be forwarded to
every other client that joined the channel and still need to add operators and regular users and please don't touch my code hahahaha
This commit is contained in:
mochaoui
2024-04-14 13:56:30 -05:00
parent 21f497ef0a
commit 05d3158f54
3 changed files with 291 additions and 2 deletions

View File

@@ -1,6 +1,11 @@
#ifndef SERVER_HPP
#define SERVER_HPP
#include <sstream>
#include <algorithm>
#include <cctype>
#include <unistd.h> // Include for the send function
#include <cstring> // Include for the strlen function
#include <iostream>
#include <cstdlib>
#include <csignal>
@@ -10,8 +15,10 @@
#include <poll.h>
#include "Client.hpp"
#include <cstring>
#include <map>
#define BUFFER_SIZE 1024
class Server {
private:
int _port;
@@ -20,10 +27,24 @@ class Server {
std::string _password;
std::vector<struct pollfd> _fds;
std::vector<Client> _clients;
// THAT'S THA DATA OF TOOOP GGG START FROM THERE .
std::map<int, std::string> nicknames; // Replace unordered_map with map
std::map<int, std::string> usernames; // Replace unordered_map with map
std::map<std::string, std::vector<std::string> > channels; //here a chanel name and list of client in every chanel
public:
Server();
~Server();
// THAT'S MY FUNCTIONS START FROM THERE
void setNickname(int fd, const std::string& nickname);
void setUsername(int fd, const std::string& username);
void createChannel(const std::string& channel, const std::string& nickname);
void handlePrivateMessage(int senderFd, const std::string& recipient, const std::string& message);
void broadcastMessage(const std::string& channel, const std::string& senderNickname, const std::string& msg);
int findUserFd1(const std::string& nickname);
// AND END HERE.
void parseArgs(int ac, char **av);
static void receiveSignal(int signum);
void init();