mirror of
https://github.com/Ladebeze66/ft_irc.git
synced 2026-11-09 13:17:13 +01:00
fef
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/16 15:23:58 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/19 19:18:11 by fgras-ca ### ########.fr */
|
||||
/* Created: 2024/05/21 18:09:05 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/21 19:46:40 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
#include "Client.hpp"
|
||||
#include "Server.hpp"
|
||||
#include "Channel.hpp"
|
||||
#include "CommandHandler.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "RPL.hpp"
|
||||
#include "Who.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
@@ -26,12 +29,20 @@
|
||||
class Server;
|
||||
class Client;
|
||||
class Channel;
|
||||
class CommandHandler;
|
||||
|
||||
void sendWelcomeMessages(Client *client, Server *server);
|
||||
void sendMotd(Client *client, Server *server);
|
||||
void broadcastChannelList(Client *client, Server *server);
|
||||
void handlePartCommand(Server *server, Client *client, const std::string &command);
|
||||
void handleNickCommand(Server *server, Client *client, const std::string &command);
|
||||
void handlePrivmsgCommand(Server *server, Client *client, const std::string &command);
|
||||
class AdditionalCommands
|
||||
{
|
||||
private:
|
||||
Server *_server;
|
||||
CommandHandler *_commandhandler;
|
||||
public:
|
||||
AdditionalCommands(Server *server);
|
||||
void processCommand(Client *client, const std::string &command);
|
||||
void broadcastChannelList(Client *client, Server *server);
|
||||
void handlePartCommand(Server *server, Client *client, const std::string &command);
|
||||
void handleNickCommand(Server *server, Client *client, const std::string &command);
|
||||
void handlePrivmsgCommand(Server *server, Client *client, const std::string &command);
|
||||
};
|
||||
|
||||
#endif // ADDITIONALCOMMANDS_HPP
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:41:35 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/19 15:14:50 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/21 19:26:51 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -17,11 +17,16 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include "RPL.hpp"
|
||||
|
||||
#include "RPL.hpp"
|
||||
#include "Client.hpp"
|
||||
#include "Server.hpp"
|
||||
|
||||
class Server;
|
||||
class Client;
|
||||
|
||||
class Channel {
|
||||
class Channel
|
||||
{
|
||||
public:
|
||||
Channel(const std::string &name);
|
||||
~Channel();
|
||||
@@ -33,6 +38,8 @@ public:
|
||||
const std::vector<Client *> &getClients() const;
|
||||
void addOperator(Client *client);
|
||||
bool isOperator(Client *client) const;
|
||||
bool hasClient(Client *client) const; // Ajouté
|
||||
void broadcast(const std::string &message, Client *_client, Server *_server); // Ajouté
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
@@ -40,4 +47,4 @@ private:
|
||||
std::vector<Client *> _operators;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // CHANNEL_HPP
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:15:42 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/19 15:38:28 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/21 18:03:09 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 18:30:07 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/19 18:56:44 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/21 18:01:47 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "Channel.hpp"
|
||||
#include "Server.hpp"
|
||||
#include "CommandHandler.hpp"
|
||||
#include "AdditionalCommands.hpp"
|
||||
#include "RPL.hpp"
|
||||
#include "Utils.hpp"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 18:14:12 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/21 13:47:12 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/21 20:15:58 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -17,39 +17,42 @@
|
||||
#include "Server.hpp"
|
||||
#include "Client.hpp"
|
||||
#include "Channel.hpp"
|
||||
#include "AdditionalCommands.hpp"
|
||||
#include "Who.hpp"
|
||||
#include "CommandHandler.hpp"
|
||||
#include "AdditionalCommands.hpp"
|
||||
#include "RPL.hpp"
|
||||
#include "Join.hpp"
|
||||
#include "Welcome.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
class Server;
|
||||
class ModeWhoHandler;
|
||||
class AdditinalCommands;
|
||||
class Client;
|
||||
class Channel;
|
||||
class WhoHandler;
|
||||
class AdditionalCommands;
|
||||
|
||||
class CommandHandler
|
||||
{
|
||||
private:
|
||||
Server *_server;
|
||||
AdditionalCommands *_additionalCommands;
|
||||
|
||||
public:
|
||||
CommandHandler(Server *server);
|
||||
bool isValidNickname(const std::string& nickname);
|
||||
bool isNicknameInUse(const std::string& nickname);
|
||||
void handleNick(Client* client, const std::vector<std::string>& tokens);
|
||||
bool isValidNickname(const std::string& nickname);
|
||||
bool isNicknameInUse(const std::string& nickname);
|
||||
void handleNick(Client* client, const std::vector<std::string>& tokens);
|
||||
|
||||
void handleUser(Client* client, const std::vector<std::string>& tokens);
|
||||
void handlePingCommand(Client* client, const std::vector<std::string>& tokens);
|
||||
void handleUser(Client* client, const std::vector<std::string>& tokens);
|
||||
void handlePingCommand(Client* client, const std::vector<std::string>& tokens);
|
||||
void handleCommand(Client *client, const std::string &command);
|
||||
void handleCapCommand(Client* client, const std::vector<std::string>& tokens);
|
||||
void handlePassCommand(Client* client, const std::vector<std::string>& tokens);
|
||||
void handleCapCommand(Client* client, const std::vector<std::string>& tokens);
|
||||
void handlePassCommand(Client* client, const std::vector<std::string>& tokens);
|
||||
void handleQuitCommand(Client* client, const std::vector<std::string>& tokens);
|
||||
void handleErrorCommand(Client* client, const std::string &message);
|
||||
|
||||
void processCommand(Client *client, const std::string &command);
|
||||
void handleJoinCommand(Client *client, const std::string &channelName);
|
||||
std::string getUsersList(Channel *channel);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // COMMANDHANDLER_HPP
|
||||
34
ft_irc3/includes/Join.hpp
Normal file
34
ft_irc3/includes/Join.hpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Join.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/21 19:51:08 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/21 20:13:15 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef JOIN_HPP
|
||||
#define JOIN_HPP
|
||||
|
||||
#include "Server.hpp"
|
||||
#include "Client.hpp"
|
||||
#include "Channel.hpp"
|
||||
#include "RPL.hpp"
|
||||
|
||||
class Server;
|
||||
class Client;
|
||||
class Channel;
|
||||
|
||||
class JoinHandler
|
||||
{
|
||||
public:
|
||||
void handleJoinCommand(Client *client, const std::string &channelName, Server *server);
|
||||
|
||||
private:
|
||||
std::string getUsersList(Channel *channel);
|
||||
};
|
||||
|
||||
#endif // JOIN_HPP
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/19 21:13:24 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/21 19:44:24 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -38,6 +38,7 @@ class Client;
|
||||
class Channel;
|
||||
class ClientManager;
|
||||
class CommandHandler;
|
||||
class AdditionalCommands;
|
||||
|
||||
class Server
|
||||
{
|
||||
@@ -56,6 +57,8 @@ public:
|
||||
Client* getClientByName(const std::string &name); // Ajoutez cette méthode
|
||||
void sendChannelListToClient(Client *client);
|
||||
void disconnectClient(int clientFd);
|
||||
bool MatchFd(const pollfd& pfd, int clientFd);
|
||||
void removePollFd(int clientFd);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
27
ft_irc3/includes/Welcome.hpp
Normal file
27
ft_irc3/includes/Welcome.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Welcome.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/21 19:53:17 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/21 19:53:24 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef WELCOME_HPP
|
||||
#define WELCOME_HPP
|
||||
|
||||
#include "Client.hpp"
|
||||
#include "Server.hpp"
|
||||
#include <string>
|
||||
|
||||
class WelcomeHandler
|
||||
{
|
||||
public:
|
||||
void sendWelcomeMessages(Client *client, Server *server);
|
||||
void sendMotd(Client *client, Server *server);
|
||||
};
|
||||
|
||||
#endif // WELCOME_HPP
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/17 16:08:48 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/05/21 13:47:28 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/05/21 18:04:10 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user