IRC SERVER
The goal of this project is to make you write your own IRC server.
Quit.hpp
Go to the documentation of this file.
1 #ifndef QUIT_H
2 #define QUIT_H
3 
4 // Our includes
5 #include "../Command.hpp"
6 
7 class Quit : public Command
8 {
9  public:
10  Quit()
11  {
12  _name = "quit";
13  _description = "salir del servidor con mensaje de salida";
14  _usage = "quit";
15  _example[0] = "quit :[<Mensaje de salida>]";
16  _example[1] = "quit :Hasta la vista, baby";
17  }
18 
19  void execute()
20  {
21  std::vector<Client *> clients = _server->getRelatedClients(_sender);
22  for (size_t i = 0; i < clients.size(); i++)
23  {
24  clients[i]->message(std::string(":" + _sender->_nick + "!" + _sender->_username + "@" +
26  " QUIT :" + _message->getParams()[0] + "\n")
27  .c_str());
28  }
29 
30  std::map<std::string, Channel *> related_channels = _server->getRelatedChannels(_sender);
31  std::map<std::string, Channel *>::iterator it = related_channels.begin();
32  for (; it != related_channels.end(); it++)
33  {
34  it->second->removeClientFromChannel(_sender);
35  }
37  }
38 };
39 #endif
Quit::execute
void execute()
Definition: Quit.hpp:19
Command::_description
std::string _description
Definition: Command.hpp:12
Client::_username
std::string _username
Definition: Client.hpp:27
Command::_name
std::string _name
Definition: Command.hpp:11
Command
Definition: Command.hpp:7
Server::getRelatedClients
std::vector< Client * > getRelatedClients(Client *client)
Definition: Server.hpp:93
Quit
Definition: Quit.hpp:7
Command::_message
Message * _message
Definition: Command.hpp:21
Server::deleteClient
void deleteClient(int fd)
Definition: Server.hpp:153
Command::_example
std::map< size_t, std::string > _example
Definition: Command.hpp:16
Quit::Quit
Quit()
Definition: Quit.hpp:10
Message::getParams
std::map< size_t, std::string > getParams(void) const
Definition: message.cpp:79
Command::_usage
std::string _usage
Definition: Command.hpp:13
Server::getRelatedChannels
std::map< std::string, Channel * > getRelatedChannels(Client *client)
Definition: Server.hpp:114
Command::_sender
Client * _sender
Definition: Command.hpp:19
Client::_nick
std::string _nick
Definition: Client.hpp:26
Client::_fd
int _fd
Definition: Client.hpp:25
Client::_servername
std::string _servername
Definition: Client.hpp:30
Command::_server
Server * _server
Definition: Command.hpp:20