ft_irc 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
QuitCommand.cpp
[詳解]
1
8#include "QuitCommand.hpp"
9#include "Channel.hpp"
10#include "Client.hpp"
11#include "Replies.hpp"
12#include "Server.hpp"
13#include <vector>
14
16
18
20 std::string quitMessage;
21 if (args.empty()) {
22 quitMessage = "";
23 } else {
24 quitMessage = args[0];
25 }
26 client->markForDisconnect(quitMessage);
27
28 // Notify all channels the client is in
29 std::vector<Channel *> channelsToNotify = client->getChannels(); // Copy of channels
30
31 for (size_t i = 0; i < channelsToNotify.size(); ++i) {
32 Channel *channel = channelsToNotify[i];
33 std::string fullQuitMessage = client->getPrefix() + " QUIT :" + quitMessage + "\r\n";
34 channel->broadcast(fullQuitMessage, client);
35 channel->removeMember(client);
36 client->removeChannel(channel); // Remove channel from client's list
37 }
38}
Manages channel members and states.
Manages client connection and state.
Handles the QUIT command.
Defines IRC numeric replies and error messages.
Core IRC server implementation.
チャンネルのメンバーと状態を管理するクラス。
Definition Channel.hpp:25
void broadcast(const std::string &message, Client *excludeClient)
Definition Channel.cpp:39
void removeMember(Client *client)
Definition Channel.cpp:32
Represents an IRC client connected to the server.
Definition Client.hpp:25
const std::vector< Channel * > & getChannels() const
Gets the list of channels the client is in.
Definition Client.cpp:43
void removeChannel(Channel *channel)
Removes a channel from the client's list of joined channels.
Definition Client.cpp:83
std::string getPrefix() const
Generates the client's IRC prefix (e.g., :nick!user@host).
Definition Client.cpp:50
void markForDisconnect(const std::string &message)
Marks the client for disconnection with a specified message.
Definition Client.cpp:68
Abstract base class (interface) for all IRC commands.
Definition ICommand.hpp:26
QuitCommand(Server *server)
Constructs a QuitCommand object.
void execute(Client *client, const std::vector< std::string > &args)
Executes the QUIT command.
~QuitCommand()
Destroys the QuitCommand object.
Implements the core IRC server functionality as a Singleton.
Definition Server.hpp:49
T empty(T... args)
T size(T... args)