-storing the channel in another file with the channel requirment and the client : it's when registerd in the irssi client with the pass and the nick and the user all this data stored in the client file and make the irssi client connecte with the server , after tha handle the join commande to make the user join a channel and handle the brodcast msg to all the clients in the channel

This commit is contained in:
mochaoui
2024-04-17 06:16:22 -05:00
parent 0399adf8e1
commit 7a54b230e3
8 changed files with 337 additions and 44 deletions

View File

@@ -16,6 +16,7 @@
#include "Client.hpp"
#include <cstring>
#include <map>
#include "channel.hpp"
#define BUFFER_SIZE 1024
@@ -31,7 +32,8 @@ class Server {
std::map<int, std::string> nicknames; // Replace unordered_map with map
std::map<int, std::string> usernamesoperators; // Replace unordered_map with map
std::map<int, std::string> usernamesregulars;
std::map<std::string, std::vector<std::string> > channels; //here a chanel name and list of client in every chanel
// std::map<std::string, std::vector<std::string> > channels; //here a chanel name and list of client in every chanel
std::map<std::string, Channel> channels;
@@ -40,9 +42,11 @@ class Server {
~Server();
// THAT'S MY FUNCTIONS START FROM THERE
void setNickname(int fd, const std::string& nickname);
std::string getPassowrd() const;
void setPassword(const std::string& password);
void setUsernameoperators(int fd, const std::string& username);
void setUsernameregular(int fd, const std::string& username);
void createChannel(const std::string& channel, const std::string& nickname);
void createChannel(const std::string& channel, const std::string& nickname, int fd);
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);
@@ -62,6 +66,14 @@ class Server {
void handleClientData(int fd);
void clientCleanup(int fd);
void closeFds();
void debugPrintChannels() {
std::cout << "List of channels:" << std::endl;
std::map<std::string, Channel>::iterator it;
for (it = channels.begin(); it != channels.end(); ++it) {
std::cout << "- " << it->first << std::endl; // Print the channel name (it->first)
}
}
};
#endif