This commit is contained in:
Ladebeze66
2024-06-05 10:20:59 +02:00
parent 0c3c24a2f1
commit 975373f1d8
13 changed files with 176 additions and 90 deletions

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/15 12:41:35 by fgras-ca #+# #+# */
/* Updated: 2024/06/01 18:49:53 by fgras-ca ### ########.fr */
/* Updated: 2024/06/04 16:12:23 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -51,6 +51,7 @@ class Channel
const std::string &getTopicSetter() const;
time_t getTopicTime() const;
void setTopic(const std::string &topic, const std::string &setter);
std::string getKey();
void setClientLimit(size_t limit);
size_t getClientLimit() const;

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/15 12:15:42 by fgras-ca #+# #+# */
/* Updated: 2024/06/01 18:47:36 by fgras-ca ### ########.fr */
/* Updated: 2024/06/05 09:34:30 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -43,6 +43,8 @@ public:
void setAway(bool away);
std::string getKey() const;
void setkey(const std::string &key);
char buffer[1024];
char buffer2[1024];
private:
int _fd;

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/15 18:30:07 by fgras-ca #+# #+# */
/* Updated: 2024/06/01 18:50:30 by fgras-ca ### ########.fr */
/* Updated: 2024/06/05 09:37:10 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -42,6 +42,7 @@ class ClientManager
public:
ClientManager(Server *server);
void acceptClient();
void handleClientNext(int client_fd, char * buffer, int bytes_received);
void handleClient(int client_fd);
void removeClient(int client_fd);

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/30 11:12:57 by fgras-ca #+# #+# */
/* Updated: 2024/06/01 18:52:10 by fgras-ca ### ########.fr */
/* Updated: 2024/06/04 14:00:47 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -43,7 +43,7 @@ class ModeHandler
void setChannelMode(Client *client, Channel* channel, const std::string& mode, bool adding, const std::string& argument);
void applyModeL(Client *client, Channel* channel, bool adding, const std::string& argument);
void applyModeI(Channel* channel, bool adding);
void applyModeI(Client *client, Channel* channel, bool adding);
void applyModeK(Client *client, Channel* channel, bool adding, const std::string& argument);
void applyModeT(Channel* channel, bool adding);
void applyModeO(Client *client, Channel* channel, bool adding, const std::string& argument);

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/19 15:12:47 by fgras-ca #+# #+# */
/* Updated: 2024/06/01 18:58:37 by fgras-ca ### ########.fr */
/* Updated: 2024/06/04 16:06:40 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,6 +18,7 @@
#include "Client.hpp"
#include "Utils.hpp"
#include "Channel.hpp"
#define SERVER_NAME "IRC_Server"
#define SERVER_VERSION "1.0"
@@ -411,6 +412,22 @@ inline std::string ERR_INVALIDKEY(Client* client, const std::string& channel)
return oss.str();
}
inline std::string ERR_KEYSET(Client* client, const std::string& channel)
{
std::ostringstream oss;
oss << ":" << SERVER_NAME << " 467 " << CLIENT_NICK(client) << " " << channel
<< " :Channel key already set\r\n";
return oss.str();
}
inline std::string ERR_LINKSET(Client* client, const std::string& channel)
{
std::ostringstream oss;
oss << ":" << SERVER_NAME << " 469 " << CLIENT_NICK(client) << " " << channel
<< " :No key set\r\n";
return oss.str();
}
inline std::string ERR_CHANNELISFULL(Client* client, const std::string& channel)
{
std::ostringstream oss;
@@ -517,4 +534,11 @@ inline std::string RPL_CAPEND(Client *client)
return oss.str();
}
inline std::string MODEACCEPTMESSAGE(Client *client, std::string channel, const std::string& mode)
{
std::ostringstream oss;
oss << ":" << client->getNickname() << " MODE " << channel << " " << mode << " :" << "\r\n";
return oss.str();
}
#endif

View File

@@ -6,7 +6,7 @@
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */
/* Updated: 2024/06/01 19:01:40 by fgras-ca ### ########.fr */
/* Updated: 2024/06/04 15:03:28 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
@@ -59,7 +59,6 @@ class Server
void broadcast(const std::string &message);
Client* getClientByName(const std::string &name);
Channel* getChannelByName(const std::string &name);
void sendChannelListToClient(Client *client);
void disconnectClient(int clientFd);
bool MatchFd(const pollfd& pfd, int clientFd);
void removePollFd(int clientFd);
@@ -84,9 +83,6 @@ class Server
private:
void initServer();
void handleServerCommands();
void acceptClient();
void removeClient(int client_fd);
};
#endif