Client class now has getters and setters, and server has 4 functions for main loop

This commit is contained in:
aortigos
2026-04-16 22:28:47 +02:00
parent b925cc74c7
commit 00a08b4f30
5 changed files with 139 additions and 56 deletions

View File

@@ -18,16 +18,33 @@
Client::Client()
{
std::cout << "Client default constructor called" << std::endl;
// std::cout << "Client default constructor called" << std::endl;
}
Client::Client(int fd) : fd(fd), registered(false), authenticated(false)
{
std::cout << "Client will use fd: " << fd << std::endl;
// std::cout << "Client will use fd: " << fd << std::endl;
}
Client::~Client()
{
std::cout << "Client destructor called" << std::endl;
// std::cout << "Client destructor called" << std::endl;
}
// Getters
int Client::getFd() const { return (this->fd); }
std::string Client::getNick() const { return (this->nick); }
std::string Client::getUsername() const { return (this->username); }
std::string Client::getRealname() const { return (this->realname); }
std::string Client::getBuffer() const { return (this->buffer); }
bool Client::isAuthenticated() const { return (this->authenticated); }
bool Client::isRegistered() const { return (this->registered); }
// Seters
void Client::setNick(std::string nick) { this->nick = nick; }
void Client::setUsername(std::string username) { this->username = username; }
void Client::setRealname(std::string realname) { this->realname = realname; }
void Client::setAuthenticated(bool value) { this->authenticated = value; }
void Client::setRegistered(bool value) { this->authenticated = value; }
void Client::appendBuffer(std::string data) { this->buffer += data; }
void Client::clearBuffer() { this->buffer.clear(); }

View File

@@ -31,6 +31,27 @@ class Client
Client();
Client(int fd);
~Client();
// Getters
int getFd() const;
std::string getNick() const;
std::string getUsername() const;
std::string getRealname() const;
std::string getBuffer() const;
bool isAuthenticated() const;
bool isRegistered() const;
// Seters
void setNick(std::string nick);
void setUsername(std::string username);
void setRealname(std::string realname);
void setAuthenticated(bool value);
void setRegistered(bool value);
void appendBuffer(std::string data);
void clearBuffer();
};
#endif