ft_irc 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
PassCommand.cpp
[詳解]
1
8#include "PassCommand.hpp"
9#include "Client.hpp"
10#include "Replies.hpp"
11#include "Server.hpp"
12
14
16 if (client->isRegistered()) {
19 return;
20 }
21
22 if (args.empty()) {
24 params.push_back("PASS");
25 client->sendMessage(
26 formatReply(this->_server->getServerName(), client->getNickname(), ERR_NEEDMOREPARAMS, params));
27 return;
28 }
29
30 if (this->_server->getPassword() == args[0]) {
31 client->setAuthenticated(true);
32 } else {
35 }
36}
Manages client connection and state.
Handles the PASS command.
std::string formatReply(const std::string &serverName, const std::string &clientNickname, const std::string &replyCodeAndText)
Formats an IRC reply message without extra parameters.
Definition Replies.cpp:14
Defines IRC numeric replies and error messages.
#define ERR_PASSWDMISMATCH
Definition Replies.hpp:78
#define ERR_ALREADYREGISTRED
Definition Replies.hpp:77
#define ERR_NEEDMOREPARAMS
Definition Replies.hpp:76
Core IRC server implementation.
Represents an IRC client connected to the server.
Definition Client.hpp:25
bool isRegistered() const
Checks if the client is registered.
Definition Client.cpp:33
virtual void sendMessage(const std::string &message) const
Sends a message to the client by appending it to the send buffer.
Definition Client.cpp:135
const std::string & getNickname() const
Gets the client's nickname.
Definition Client.cpp:25
void setAuthenticated(bool value)
Sets the client's authentication status.
Definition Client.cpp:64
Abstract base class (interface) for all IRC commands.
Definition ICommand.hpp:26
Server * _server
Pointer to the IRC server instance.
Definition ICommand.hpp:28
PassCommand(Server *server)
Constructs a PassCommand object.
void execute(Client *client, const std::vector< std::string > &args)
Executes the PASS command.
Implements the core IRC server functionality as a Singleton.
Definition Server.hpp:49
const std::string & getPassword() const
Gets the server's password.
Definition Server.cpp:379
const std::string & getServerName() const
Gets the server's name.
Definition Server.cpp:381
T empty(T... args)
T push_back(T... args)