mirror of
https://github.com/Ladebeze66/ft_irc.git
synced 2025-12-17 06:28:03 +01:00
test
This commit is contained in:
parent
6da78f6457
commit
714ff9e410
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/21 18:09:05 by fgras-ca #+# #+# */
|
/* Created: 2024/05/21 18:09:05 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/11 13:30:49 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:39:51 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ class Server;
|
|||||||
class Client;
|
class Client;
|
||||||
class Channel;
|
class Channel;
|
||||||
class BotFilter;
|
class BotFilter;
|
||||||
|
class KickHandler;
|
||||||
class AdditionalCommands
|
class AdditionalCommands
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -41,6 +42,7 @@ class AdditionalCommands
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
AdditionalCommands(Server *server);
|
AdditionalCommands(Server *server);
|
||||||
|
~AdditionalCommands();
|
||||||
void processCommand(Client *client, const std::string &command);
|
void processCommand(Client *client, const std::string &command);
|
||||||
void broadcastChannelList(Client *client, Server *server);
|
void broadcastChannelList(Client *client, Server *server);
|
||||||
void handlePartCommand(Server *server, Client *client, const std::string &command);
|
void handlePartCommand(Server *server, Client *client, const std::string &command);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/06/06 11:44:44 by fgras-ca #+# #+# */
|
/* Created: 2024/06/06 11:44:44 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/10 14:46:42 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:02:00 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -32,6 +32,7 @@ class BotFilter
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BotFilter(Server* server);
|
BotFilter(Server* server);
|
||||||
|
~BotFilter();
|
||||||
void loadBadWords(const std::string& fileName);
|
void loadBadWords(const std::string& fileName);
|
||||||
bool checkMessage(Client* client, Channel* channel, const std::string& message);
|
bool checkMessage(Client* client, Channel* channel, const std::string& message);
|
||||||
void warnClient(Client* client, Channel* channel);
|
void warnClient(Client* client, Channel* channel);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:41:35 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:41:35 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/06 21:03:34 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:02:31 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:15:42 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:15:42 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/06 19:59:39 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 12:58:08 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,11 +15,13 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Client(int fd, const std::string &nickname, const std::string &user, const std::string &host, const std::string &password, const std::string &realname);
|
Client(int fd, const std::string &nickname, const std::string &user, const std::string &host, const std::string &password, const std::string &realname);
|
||||||
|
~Client();
|
||||||
|
|
||||||
int getFd() const;
|
int getFd() const;
|
||||||
const std::string &getNickname() const;
|
const std::string &getNickname() const;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 18:30:07 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 18:30:07 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/06 13:01:05 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:03:49 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ class ClientManager
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClientManager(Server *server);
|
ClientManager(Server *server);
|
||||||
|
~ClientManager();
|
||||||
void acceptClient();
|
void acceptClient();
|
||||||
void handleClientNext(int client_fd, char * buffer, int bytes_received);
|
void handleClientNext(int client_fd, char * buffer, int bytes_received);
|
||||||
void handleClient(int client_fd);
|
void handleClient(int client_fd);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 18:14:12 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 18:14:12 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 18:47:51 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:38:19 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -23,6 +23,8 @@
|
|||||||
#include "Join.hpp"
|
#include "Join.hpp"
|
||||||
#include "Welcome.hpp"
|
#include "Welcome.hpp"
|
||||||
#include "ModeHandler.hpp"
|
#include "ModeHandler.hpp"
|
||||||
|
#include "Join.hpp"
|
||||||
|
#include "Welcome.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -34,6 +36,8 @@ class Channel;
|
|||||||
class WhoHandler;
|
class WhoHandler;
|
||||||
class AdditionalCommands;
|
class AdditionalCommands;
|
||||||
class ModeHandler;
|
class ModeHandler;
|
||||||
|
class JoinHandler;
|
||||||
|
class WelcomeHandler;
|
||||||
|
|
||||||
class CommandHandler
|
class CommandHandler
|
||||||
{
|
{
|
||||||
@ -41,10 +45,12 @@ private:
|
|||||||
Server *_server;
|
Server *_server;
|
||||||
AdditionalCommands *_additionalCommands;
|
AdditionalCommands *_additionalCommands;
|
||||||
ModeHandler *_modeHandler;
|
ModeHandler *_modeHandler;
|
||||||
|
JoinHandler *_joinHandler;
|
||||||
|
WelcomeHandler *_welcomeHandler;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CommandHandler(Server *server);
|
CommandHandler(Server *server);
|
||||||
|
~CommandHandler();
|
||||||
bool isValidNickname(const std::string& nickname);
|
bool isValidNickname(const std::string& nickname);
|
||||||
bool isNicknameInUse(const std::string& nickname);
|
bool isNicknameInUse(const std::string& nickname);
|
||||||
void handleNick(Client* client, const std::vector<std::string>& tokens);
|
void handleNick(Client* client, const std::vector<std::string>& tokens);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 13:01:50 by fgras-ca #+# #+# */
|
/* Created: 2024/05/30 13:01:50 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 18:51:00 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:05:09 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -31,6 +31,7 @@ class InviteHandler
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InviteHandler(Server* server);
|
InviteHandler(Server* server);
|
||||||
|
~InviteHandler();
|
||||||
void handleInviteCommand(Client* client, const std::string& command);
|
void handleInviteCommand(Client* client, const std::string& command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/21 19:51:08 by fgras-ca #+# #+# */
|
/* Created: 2024/05/21 19:51:08 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/11 13:50:53 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:31:09 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -19,7 +19,6 @@
|
|||||||
#include "Channel.hpp"
|
#include "Channel.hpp"
|
||||||
#include "RPL.hpp"
|
#include "RPL.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
#include "Server.hpp"
|
|
||||||
#include "Channel.hpp"
|
#include "Channel.hpp"
|
||||||
#include "Client.hpp"
|
#include "Client.hpp"
|
||||||
#include "AdditionalCommands.hpp"
|
#include "AdditionalCommands.hpp"
|
||||||
@ -32,10 +31,15 @@
|
|||||||
class JoinHandler
|
class JoinHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
JoinHandler(Server *server);
|
||||||
|
~JoinHandler();
|
||||||
void handleJoinCommand(Client *client, const std::string &channelName, Server *server);
|
void handleJoinCommand(Client *client, const std::string &channelName, Server *server);
|
||||||
void sendJoinSuccess(Client *client, Channel *channel, Server *server);
|
void sendJoinSuccess(Client *client, Channel *channel, Server *server);
|
||||||
std::string getUsersList(Channel *channel);
|
std::string getUsersList(Channel *channel);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Server *_server;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/06/01 16:59:42 by fgras-ca #+# #+# */
|
/* Created: 2024/06/01 16:59:42 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 18:51:26 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:10:14 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ class KickHandler
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KickHandler(Server* server);
|
KickHandler(Server* server);
|
||||||
|
~KickHandler();
|
||||||
void handleKickCommand(Client* client, const std::string& command);
|
void handleKickCommand(Client* client, const std::string& command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 11:12:57 by fgras-ca #+# #+# */
|
/* Created: 2024/05/30 11:12:57 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/08 18:53:15 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:10:55 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -33,6 +33,7 @@ class ModeHandler
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ModeHandler(Server* server);
|
ModeHandler(Server* server);
|
||||||
|
~ModeHandler();
|
||||||
void handleModeCommand(Client* client, const std::string& command);
|
void handleModeCommand(Client* client, const std::string& command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/11 13:33:28 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 12:58:02 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -23,6 +23,8 @@
|
|||||||
#include "ModeHandler.hpp"
|
#include "ModeHandler.hpp"
|
||||||
#include "TopicHandler.hpp"
|
#include "TopicHandler.hpp"
|
||||||
#include "BotFilter.hpp"
|
#include "BotFilter.hpp"
|
||||||
|
#include "Join.hpp"
|
||||||
|
#include "Welcome.hpp"
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -36,6 +38,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
|
|
||||||
class Client;
|
class Client;
|
||||||
class Channel;
|
class Channel;
|
||||||
@ -45,6 +49,8 @@ class AdditionalCommands;
|
|||||||
class ModeHandler;
|
class ModeHandler;
|
||||||
class TopicHandler;
|
class TopicHandler;
|
||||||
class BotFilter;
|
class BotFilter;
|
||||||
|
class JoinHandler;
|
||||||
|
class WelcomeHandler;
|
||||||
|
|
||||||
class Server
|
class Server
|
||||||
{
|
{
|
||||||
@ -79,6 +85,10 @@ class Server
|
|||||||
TopicHandler *_topicHandler;
|
TopicHandler *_topicHandler;
|
||||||
BotFilter *_botFilter;
|
BotFilter *_botFilter;
|
||||||
AdditionalCommands *_additionalCommands;
|
AdditionalCommands *_additionalCommands;
|
||||||
|
JoinHandler *_joinHandler;
|
||||||
|
WelcomeHandler *_welcomeHandler;
|
||||||
|
static Server *instance;
|
||||||
|
static void signalHandler(int signum);
|
||||||
|
|
||||||
friend class ClientManager;
|
friend class ClientManager;
|
||||||
friend class CommandHandler;
|
friend class CommandHandler;
|
||||||
@ -88,6 +98,7 @@ class Server
|
|||||||
private:
|
private:
|
||||||
void initServer();
|
void initServer();
|
||||||
void handleServerCommands();
|
void handleServerCommands();
|
||||||
|
bool bool_exit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 17:04:33 by fgras-ca #+# #+# */
|
/* Created: 2024/05/30 17:04:33 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:02:10 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:11:49 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ class TopicHandler
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TopicHandler(Server* server);
|
TopicHandler(Server* server);
|
||||||
|
~TopicHandler();
|
||||||
void handleTopicCommand(Client* client, const std::string& command);
|
void handleTopicCommand(Client* client, const std::string& command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/21 19:53:17 by fgras-ca #+# #+# */
|
/* Created: 2024/05/21 19:53:17 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:02:40 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:13:27 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -22,8 +22,13 @@
|
|||||||
class WelcomeHandler
|
class WelcomeHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
WelcomeHandler(Server *server);
|
||||||
|
~WelcomeHandler();
|
||||||
void sendWelcomeMessages(Client *client, Server *server);
|
void sendWelcomeMessages(Client *client, Server *server);
|
||||||
void sendMotd(Client *client, Server *server);
|
void sendMotd(Client *client, Server *server);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Server *_server;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/17 16:08:48 by fgras-ca #+# #+# */
|
/* Created: 2024/05/17 16:08:48 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:03:06 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:14:47 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -27,6 +27,7 @@ class WhoHandler
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WhoHandler(Server *server);
|
WhoHandler(Server *server);
|
||||||
|
~WhoHandler();
|
||||||
void handleWhoCommand(Client *client, const std::string &command);
|
void handleWhoCommand(Client *client, const std::string &command);
|
||||||
void handleWhoisCommand(Client *client, const std::string &command);
|
void handleWhoisCommand(Client *client, const std::string &command);
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/16 15:27:29 by fgras-ca #+# #+# */
|
/* Created: 2024/05/16 15:27:29 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/11 11:45:43 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:01:35 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -21,6 +21,9 @@ std::string toUpperCase(const std::string &str)
|
|||||||
return upperStr;
|
return upperStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AdditionalCommands::~AdditionalCommands()
|
||||||
|
{}
|
||||||
|
|
||||||
void AdditionalCommands::processCommand(Client *client, const std::string &command)
|
void AdditionalCommands::processCommand(Client *client, const std::string &command)
|
||||||
{
|
{
|
||||||
std::istringstream iss(command);
|
std::istringstream iss(command);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/06/06 11:45:43 by fgras-ca #+# #+# */
|
/* Created: 2024/06/06 11:45:43 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/10 14:56:40 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:02:19 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -24,6 +24,8 @@ void BotFilter::loadBadWords(const std::string &fileName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BotFilter::~BotFilter() {}
|
||||||
|
|
||||||
bool BotFilter::checkMessage(Client* client, Channel* channel, const std::string& message)
|
bool BotFilter::checkMessage(Client* client, Channel* channel, const std::string& message)
|
||||||
{
|
{
|
||||||
if (containsBadWords(message))
|
if (containsBadWords(message))
|
||||||
|
|||||||
@ -6,14 +6,21 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:17:42 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:17:42 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/06 20:06:29 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 12:51:56 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Client.hpp"
|
#include "Client.hpp"
|
||||||
|
|
||||||
Client::Client(int fd, const std::string &nickname, const std::string &user, const std::string &host, const std::string &password, const std::string &realname)
|
Client::Client(int fd, const std::string &nickname, const std::string &user, const std::string &host, const std::string &password, const std::string &realname)
|
||||||
: _fd(fd), _nickname(nickname), _user(user), _host(host), _password(password), _realname(realname), _authenticated(false), _operator(false), _away(false) {}
|
: _fd(fd), _nickname(nickname), _user(user), _host(host), _password(password), _realname(realname), _authenticated(false), _operator(false), _away(false)
|
||||||
|
{
|
||||||
|
std::memset(buffer, 0, sizeof(buffer));
|
||||||
|
std::memset(buffer2, 0, sizeof(buffer2));
|
||||||
|
}
|
||||||
|
|
||||||
|
Client::~Client()
|
||||||
|
{}
|
||||||
|
|
||||||
int Client::getFd() const
|
int Client::getFd() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 18:32:23 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 18:32:23 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/06 19:59:09 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 13:04:16 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -19,6 +19,11 @@ ClientManager::ClientManager(Server *server)
|
|||||||
_botFilter->loadBadWords("badwords.txt");
|
_botFilter->loadBadWords("badwords.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClientManager::~ClientManager()
|
||||||
|
{
|
||||||
|
delete _botFilter;
|
||||||
|
}
|
||||||
|
|
||||||
void ClientManager::acceptClient()
|
void ClientManager::acceptClient()
|
||||||
{
|
{
|
||||||
int client_fd = accept(_server->_server_fd, NULL, NULL);
|
int client_fd = accept(_server->_server_fd, NULL, NULL);
|
||||||
@ -33,6 +38,7 @@ void ClientManager::acceptClient()
|
|||||||
struct pollfd client_pollfd;
|
struct pollfd client_pollfd;
|
||||||
client_pollfd.fd = client_fd;
|
client_pollfd.fd = client_fd;
|
||||||
client_pollfd.events = POLLIN;
|
client_pollfd.events = POLLIN;
|
||||||
|
client_pollfd.revents = 0;
|
||||||
_server->_poll_fds.push_back(client_pollfd);
|
_server->_poll_fds.push_back(client_pollfd);
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|||||||
@ -6,14 +6,14 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 18:26:34 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 18:26:34 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/08 19:14:48 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 12:15:47 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "CommandHandler.hpp"
|
#include "CommandHandler.hpp"
|
||||||
|
|
||||||
CommandHandler::CommandHandler(Server *server)
|
CommandHandler::CommandHandler(Server *server)
|
||||||
: _server(server), _additionalCommands(new AdditionalCommands(server)), _modeHandler(new ModeHandler(server))
|
: _server(server), _additionalCommands(new AdditionalCommands(server)), _modeHandler(new ModeHandler(server)), _joinHandler(new JoinHandler(server)), _welcomeHandler(new WelcomeHandler(server))
|
||||||
{
|
{
|
||||||
// Ensure that _server is not null
|
// Ensure that _server is not null
|
||||||
if (!_server)
|
if (!_server)
|
||||||
@ -23,6 +23,14 @@ CommandHandler::CommandHandler(Server *server)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandHandler::~CommandHandler()
|
||||||
|
{
|
||||||
|
delete _welcomeHandler;
|
||||||
|
delete _joinHandler;
|
||||||
|
delete _modeHandler;
|
||||||
|
delete _additionalCommands;
|
||||||
|
}
|
||||||
|
|
||||||
void CommandHandler::handleCommand(Client* client, const std::string& command)
|
void CommandHandler::handleCommand(Client* client, const std::string& command)
|
||||||
{
|
{
|
||||||
std::vector<std::string> tokens = split(command, " \n\r\t");
|
std::vector<std::string> tokens = split(command, " \n\r\t");
|
||||||
@ -71,8 +79,7 @@ void CommandHandler::handleCommand(Client* client, const std::string& command)
|
|||||||
else if (commandType == "JOIN")
|
else if (commandType == "JOIN")
|
||||||
{
|
{
|
||||||
std::string joinParams = command.substr(command.find(" ") + 1);
|
std::string joinParams = command.substr(command.find(" ") + 1);
|
||||||
JoinHandler joinHandler;
|
_joinHandler->handleJoinCommand(client, joinParams, _server);
|
||||||
joinHandler.handleJoinCommand(client, joinParams, _server);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -248,8 +255,7 @@ void CommandHandler::handleUser(Client* client, const std::vector<std::string>&
|
|||||||
if (client->getPassword() == _server->_password && !client->getNickname().empty())
|
if (client->getPassword() == _server->_password && !client->getNickname().empty())
|
||||||
{
|
{
|
||||||
client->authenticate();
|
client->authenticate();
|
||||||
WelcomeHandler welcomeHandler;
|
_welcomeHandler->sendWelcomeMessages(client, _server);
|
||||||
welcomeHandler.sendWelcomeMessages(client, _server);
|
|
||||||
_server->log("Client " + client->getNickname() + " authenticated.", GREEN);
|
_server->log("Client " + client->getNickname() + " authenticated.", GREEN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 13:02:09 by fgras-ca #+# #+# */
|
/* Created: 2024/05/30 13:02:09 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/08 19:15:29 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:05:29 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
InviteHandler::InviteHandler(Server* server) : _server(server) {}
|
InviteHandler::InviteHandler(Server* server) : _server(server) {}
|
||||||
|
|
||||||
|
InviteHandler::~InviteHandler() {}
|
||||||
|
|
||||||
void InviteHandler::handleInviteCommand(Client* client, const std::string& command)
|
void InviteHandler::handleInviteCommand(Client* client, const std::string& command)
|
||||||
{
|
{
|
||||||
std::istringstream iss(command);
|
std::istringstream iss(command);
|
||||||
|
|||||||
@ -12,6 +12,11 @@
|
|||||||
|
|
||||||
#include "Join.hpp"
|
#include "Join.hpp"
|
||||||
|
|
||||||
|
JoinHandler::JoinHandler(Server *server) : _server(server)
|
||||||
|
{}
|
||||||
|
|
||||||
|
JoinHandler::~JoinHandler() {}
|
||||||
|
|
||||||
void JoinHandler::handleJoinCommand(Client* client, const std::string& params, Server* server)
|
void JoinHandler::handleJoinCommand(Client* client, const std::string& params, Server* server)
|
||||||
{
|
{
|
||||||
std::map<std::string, Channel*>& channels = server->getChannels();
|
std::map<std::string, Channel*>& channels = server->getChannels();
|
||||||
@ -66,7 +71,46 @@ void JoinHandler::handleJoinCommand(Client* client, const std::string& params, S
|
|||||||
it->second->broadcast(partMsg.str(), client, server);
|
it->second->broadcast(partMsg.str(), client, server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Leave all channels
|
|
||||||
|
//////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*std::vector<std::string> channels = split(channelNames, ",");
|
||||||
|
std::map<std::string, Channel *> &channelMap = server->getChannels();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < channels.size(); ++i)
|
||||||
|
{
|
||||||
|
std::string &channelName = channels[i];
|
||||||
|
if (channelMap.find(channelName) == channelMap.end())
|
||||||
|
{
|
||||||
|
server->sendToClient(client->getFd(), ERR_NOSUCHCHANNEL(client, channelName));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Channel *channel = channelMap[channelName];
|
||||||
|
if (!channel->hasClient(client)) {
|
||||||
|
server->sendToClient(client->getFd(), ERR_NOTONCHANNEL(client, channelName));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel->removeClient(client);
|
||||||
|
|
||||||
|
std::ostringstream partMsg;
|
||||||
|
partMsg << ":" << client->getNickname() << " PART " << channelName << " Leaving" << "\r\n";
|
||||||
|
server->sendToClient(client->getFd(), partMsg.str());
|
||||||
|
|
||||||
|
channel->broadcast(partMsg.str(), client, server);
|
||||||
|
|
||||||
|
if (channel->isEmpty())
|
||||||
|
{
|
||||||
|
delete channel;
|
||||||
|
channelMap.erase(channelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
server->log("Client " + client->getNickname() + " left channel " + channelName, MAGENTA);
|
||||||
|
}
|
||||||
|
// Leave all channels*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/06/01 17:00:31 by fgras-ca #+# #+# */
|
/* Created: 2024/06/01 17:00:31 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/08 19:16:10 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:40:37 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
KickHandler::KickHandler(Server* server) : _server(server) {}
|
KickHandler::KickHandler(Server* server) : _server(server) {}
|
||||||
|
|
||||||
|
KickHandler::~KickHandler() {}
|
||||||
|
|
||||||
void KickHandler::handleKickCommand(Client* client, const std::string& command)
|
void KickHandler::handleKickCommand(Client* client, const std::string& command)
|
||||||
{
|
{
|
||||||
std::vector<std::string> tokens = split(command, " ");
|
std::vector<std::string> tokens = split(command, " ");
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 11:13:08 by fgras-ca #+# #+# */
|
/* Created: 2024/05/30 11:13:08 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/11 11:27:28 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:11:16 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
ModeHandler::ModeHandler(Server* server) : _server(server) {}
|
ModeHandler::ModeHandler(Server* server) : _server(server) {}
|
||||||
|
|
||||||
|
ModeHandler::~ModeHandler() {}
|
||||||
|
|
||||||
void ModeHandler::handleModeCommand(Client* client, const std::string& command)
|
void ModeHandler::handleModeCommand(Client* client, const std::string& command)
|
||||||
{
|
{
|
||||||
_server->log("Received MODE command: " + command, BLUE);
|
_server->log("Received MODE command: " + command, BLUE);
|
||||||
|
|||||||
@ -6,26 +6,34 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:17:12 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:17:12 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/11 13:34:13 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 12:45:22 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Server.hpp"
|
#include "Server.hpp"
|
||||||
|
|
||||||
|
Server *Server::instance = NULL;
|
||||||
|
|
||||||
Server::Server(int port, const std::string &password)
|
Server::Server(int port, const std::string &password)
|
||||||
: _port(port), _password(password), _clientManager(new ClientManager(this)), _commandHandler(new CommandHandler(this)), _modeHandler(new ModeHandler(this)), _topicHandler(new TopicHandler(this)), _botFilter(new BotFilter(this)), _additionalCommands(new AdditionalCommands(this))
|
: _port(port), _password(password), _clientManager(new ClientManager(this)), _commandHandler(new CommandHandler(this)), _modeHandler(new ModeHandler(this)), _topicHandler(new TopicHandler(this)), _botFilter(new BotFilter(this)), _additionalCommands(new AdditionalCommands(this)), _joinHandler(new JoinHandler(this)), _welcomeHandler(new WelcomeHandler(this))
|
||||||
{
|
{
|
||||||
initServer();
|
initServer();
|
||||||
_botFilter = new BotFilter(this);
|
|
||||||
_botFilter->loadBadWords("badwords.txt");
|
_botFilter->loadBadWords("badwords.txt");
|
||||||
|
bool_exit = 0;
|
||||||
|
instance = this; // Stocke l'instance actuelle
|
||||||
|
signal(SIGINT, Server::signalHandler); // Enregistre le gestionnaire de signal
|
||||||
}
|
}
|
||||||
|
|
||||||
Server::~Server()
|
Server::~Server()
|
||||||
{
|
{
|
||||||
delete _clientManager;
|
delete _clientManager;
|
||||||
|
delete _welcomeHandler;
|
||||||
|
delete _joinHandler;
|
||||||
delete _commandHandler;
|
delete _commandHandler;
|
||||||
delete _topicHandler;
|
delete _topicHandler;
|
||||||
delete _botFilter;
|
delete _botFilter;
|
||||||
|
delete _modeHandler;
|
||||||
|
delete _additionalCommands;
|
||||||
|
|
||||||
for (std::map<int, Client*>::iterator it = _clients.begin(); it != _clients.end(); ++it)
|
for (std::map<int, Client*>::iterator it = _clients.begin(); it != _clients.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -78,6 +86,15 @@ void Server::initServer()
|
|||||||
log("Server initialized.", GREEN);
|
log("Server initialized.", GREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server::signalHandler(int signum)
|
||||||
|
{
|
||||||
|
if (signum == SIGINT)
|
||||||
|
{
|
||||||
|
instance->bool_exit = 1; // Définit bool_exit à 1 lorsque Ctrl-C est capturé
|
||||||
|
std::cout << RED << "SIGINT detected" << RESET << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Server::run()
|
void Server::run()
|
||||||
{
|
{
|
||||||
struct pollfd server_pollfd;
|
struct pollfd server_pollfd;
|
||||||
@ -86,22 +103,24 @@ void Server::run()
|
|||||||
server_pollfd.revents = 0;
|
server_pollfd.revents = 0;
|
||||||
_poll_fds.push_back(server_pollfd);
|
_poll_fds.push_back(server_pollfd);
|
||||||
|
|
||||||
|
|
||||||
struct pollfd stdin_pollfd;
|
struct pollfd stdin_pollfd;
|
||||||
stdin_pollfd.fd = STDIN_FILENO;
|
stdin_pollfd.fd = STDIN_FILENO;
|
||||||
stdin_pollfd.events = POLLIN;
|
stdin_pollfd.events = POLLIN;
|
||||||
stdin_pollfd.revents = 0;
|
stdin_pollfd.revents = 0;
|
||||||
_poll_fds.push_back(stdin_pollfd);
|
_poll_fds.push_back(stdin_pollfd);
|
||||||
|
|
||||||
while (true)
|
bool running = true;
|
||||||
|
|
||||||
|
while (running)
|
||||||
{
|
{
|
||||||
|
if (bool_exit == 1)
|
||||||
|
return;
|
||||||
int poll_count = poll(&_poll_fds[0], _poll_fds.size(), -1);
|
int poll_count = poll(&_poll_fds[0], _poll_fds.size(), -1);
|
||||||
if (poll_count == -1)
|
if (poll_count == -1)
|
||||||
{
|
{
|
||||||
log("Poll error.", RED);
|
log("Poll error.", RED);
|
||||||
exit(EXIT_FAILURE);
|
return; // Vous pouvez remplacer par une gestion d'erreur plus propre
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < _poll_fds.size(); ++i)
|
for (size_t i = 0; i < _poll_fds.size(); ++i)
|
||||||
{
|
{
|
||||||
if (_poll_fds[i].revents & POLLIN)
|
if (_poll_fds[i].revents & POLLIN)
|
||||||
@ -124,6 +143,7 @@ void Server::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::map<std::string, Channel *> &Server::getChannels()
|
std::map<std::string, Channel *> &Server::getChannels()
|
||||||
{
|
{
|
||||||
return _channels;
|
return _channels;
|
||||||
@ -141,8 +161,9 @@ void Server::handleServerCommands()
|
|||||||
|
|
||||||
if (command == "quit")
|
if (command == "quit")
|
||||||
{
|
{
|
||||||
log("Server shutting down.", YELLOW);
|
bool_exit = 1;
|
||||||
exit(EXIT_SUCCESS);
|
//log("Server shutting down.", YELLOW);
|
||||||
|
//exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
else if (command == "channels")
|
else if (command == "channels")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 17:04:58 by fgras-ca #+# #+# */
|
/* Created: 2024/05/30 17:04:58 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/08 19:17:37 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:12:14 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
TopicHandler::TopicHandler(Server* server) : _server(server) {}
|
TopicHandler::TopicHandler(Server* server) : _server(server) {}
|
||||||
|
|
||||||
|
TopicHandler::~TopicHandler() {}
|
||||||
|
|
||||||
void TopicHandler::handleTopicCommand(Client* client, const std::string& command)
|
void TopicHandler::handleTopicCommand(Client* client, const std::string& command)
|
||||||
{
|
{
|
||||||
_server->log("Received TOPIC command: " + command, "\033[1;34m");
|
_server->log("Received TOPIC command: " + command, "\033[1;34m");
|
||||||
|
|||||||
@ -6,12 +6,16 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/21 17:53:52 by fgras-ca #+# #+# */
|
/* Created: 2024/05/21 17:53:52 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/05/30 16:43:14 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:14:28 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "Welcome.hpp"
|
#include "Welcome.hpp"
|
||||||
|
|
||||||
|
WelcomeHandler::WelcomeHandler(Server *server) : _server(server) {}
|
||||||
|
|
||||||
|
WelcomeHandler::~WelcomeHandler() {}
|
||||||
|
|
||||||
void WelcomeHandler::sendWelcomeMessages(Client *client, Server *server)
|
void WelcomeHandler::sendWelcomeMessages(Client *client, Server *server)
|
||||||
{
|
{
|
||||||
server->sendToClient(client->getFd(), RPL_WELCOME(client));
|
server->sendToClient(client->getFd(), RPL_WELCOME(client));
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/17 16:09:20 by fgras-ca #+# #+# */
|
/* Created: 2024/05/17 16:09:20 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/07 13:43:54 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/12 11:15:09 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -17,6 +17,8 @@ WhoHandler::WhoHandler(Server *server)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WhoHandler::~WhoHandler() {}
|
||||||
|
|
||||||
void WhoHandler::handleWhoCommand(Client *client, const std::string &command)
|
void WhoHandler::handleWhoCommand(Client *client, const std::string &command)
|
||||||
{
|
{
|
||||||
std::istringstream iss(command);
|
std::istringstream iss(command);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user