|
ft_irc 1.0
|
Implements the core IRC server functionality as a Singleton. [詳解]
#include <Server.hpp>

公開メンバ関数 | |
| ~Server () | |
| Destroys the Server object, cleaning up all clients, channels, and the command manager. | |
| void | run () |
| Starts the IRC server, setting up the socket and entering the main event loop. | |
| void | addTestClient (Client *client) |
| Adds a client directly to the server's management for testing purposes. | |
| void | acceptNewClient () |
| Accepts a new incoming client connection. | |
| void | removeClient (int fd) |
| Removes a client from the server, closing its socket and freeing resources. | |
| Client * | getClient (int fd) |
| Retrieves a Client object by its file descriptor. | |
| Client * | getClientByNickname (const std::string &nickname) |
| Retrieves a Client object by its nickname. | |
| void | addChannel (Channel *channel) |
| Adds a new channel to the server. | |
| Channel * | getChannel (const std::string &name) |
| Retrieves a Channel object by its name. | |
| void | removeChannel (const std::string &name) |
| Removes a channel from the server, deleting the Channel object. | |
| const std::map< std::string, Channel * > & | getChannels () const |
| Gets a constant reference to the map of channels managed by the server. | |
| const std::map< int, Client * > & | getClients () const |
| Gets a constant reference to the map of clients managed by the server. | |
| const std::string & | getPassword () const |
| Gets the server's password. | |
| const std::string & | getServerName () const |
| Gets the server's name. | |
静的公開メンバ関数 | |
| static Server * | getInstance (int port=-1, const std::string &password="") |
| Gets the single instance of the Server (Singleton pattern). | |
| static void | resetInstance () |
| Resets the singleton instance of the Server for testing purposes. | |
Implements the core IRC server functionality as a Singleton.
This class is responsible for setting up the network socket, managing client connections, handling I/O events using poll(), dispatching commands through the CommandManager, and managing channels and clients. It follows the Singleton design pattern to ensure only one server instance exists.
Server.hpp の 49 行目に定義があります。
| Server::~Server | ( | ) |
Destroys the Server object, cleaning up all clients, channels, and the command manager.
Server.cpp の 77 行目に定義があります。
| void Server::acceptNewClient | ( | ) |
Accepts a new incoming client connection.
Creates a new Client object, sets its socket to non-blocking, and adds it to the server's list of managed clients and pollfds.
Server.cpp の 262 行目に定義があります。
| void Server::addChannel | ( | Channel * | channel | ) |
Adds a new channel to the server.
| channel | A pointer to the Channel object to add. |
Server.cpp の 400 行目に定義があります。
| void Server::addTestClient | ( | Client * | client | ) |
Adds a client directly to the server's management for testing purposes.
This bypasses the normal socket acceptance process and is intended for injecting mock clients in unit tests.
| client | A pointer to the Client object to add. |
Server.cpp の 48 行目に定義があります。
| Channel * Server::getChannel | ( | const std::string & | name | ) |
Retrieves a Channel object by its name.
| name | The name of the channel. |
Server.cpp の 406 行目に定義があります。
| const std::map< std::string, Channel * > & Server::getChannels | ( | ) | const |
Gets a constant reference to the map of channels managed by the server.
Server.cpp の 422 行目に定義があります。
| Client * Server::getClient | ( | int | fd | ) |
Retrieves a Client object by its file descriptor.
| fd | The file descriptor of the client. |
Server.cpp の 383 行目に定義があります。
| Client * Server::getClientByNickname | ( | const std::string & | nickname | ) |
Retrieves a Client object by its nickname.
| nickname | The nickname of the client. |
Server.cpp の 391 行目に定義があります。
Gets a constant reference to the map of clients managed by the server.
Server.cpp の 424 行目に定義があります。
|
static |
Gets the single instance of the Server (Singleton pattern).
| port | The port number for server initialization (used only on first call). |
| password | The password for server initialization (used only on first call). |
Server.cpp の 63 行目に定義があります。
| const std::string & Server::getPassword | ( | ) | const |
| const std::string & Server::getServerName | ( | ) | const |
| void Server::removeChannel | ( | const std::string & | name | ) |
Removes a channel from the server, deleting the Channel object.
| name | The name of the channel to remove. |
Server.cpp の 414 行目に定義があります。
| void Server::removeClient | ( | int | fd | ) |
Removes a client from the server, closing its socket and freeing resources.
| fd | The file descriptor of the client to remove. |
Server.cpp の 290 行目に定義があります。
|
static |
Resets the singleton instance of the Server for testing purposes.
This method should only be used in test environments to ensure a clean slate before each test case.
Server.cpp の 43 行目に定義があります。
| void Server::run | ( | ) |
Starts the IRC server, setting up the socket and entering the main event loop.
| std::runtime_error | if socket setup fails. |
Server.cpp の 101 行目に定義があります。