Nick fixed
This commit is contained in:
@@ -60,7 +60,9 @@ int Server::run()
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
poll(this->fds.data(), this->fds.size(), -1);
|
int ret = poll(this->fds.data(), this->fds.size(), -1);
|
||||||
|
if (ret < 0)
|
||||||
|
break ;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < this->fds.size(); i++)
|
for(unsigned int i = 0; i < this->fds.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -114,7 +116,7 @@ void Server::readClient(int fd)
|
|||||||
while ((pos = clientBuf.find('\n')) != std::string::npos)
|
while ((pos = clientBuf.find('\n')) != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string line = clientBuf.substr(0, pos);
|
std::string line = clientBuf.substr(0, pos);
|
||||||
clients[fd].clearBuffer();
|
clientBuf = clientBuf.substr(pos + 1);
|
||||||
|
|
||||||
if (!line.empty() && line[line.size() - 1] == '\r')
|
if (!line.empty() && line[line.size() - 1] == '\r')
|
||||||
line.erase(line.size() - 1);
|
line.erase(line.size() - 1);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/04/17 11:56:55 by aortigos #+# #+# */
|
/* Created: 2026/04/17 11:56:55 by aortigos #+# #+# */
|
||||||
/* Updated: 2026/04/17 12:45:36 by aortigos ### ########.fr */
|
/* Updated: 2026/04/17 14:19:29 by aortigos ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -47,13 +47,15 @@ void Server::cmd_nick(int fd, std::istringstream &ss)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clients[fd].setNick(args);
|
|
||||||
|
|
||||||
std::string msg = ":"
|
std::string msg = ":"
|
||||||
+ clients[fd].getNick()
|
+ clients[fd].getNick()
|
||||||
+ " NICK "
|
+ " NICK "
|
||||||
+ args
|
+ args
|
||||||
+ "\r\n";
|
+ "\r\n";
|
||||||
|
|
||||||
|
clients[fd].setNick(args);
|
||||||
|
|
||||||
send(fd, msg.c_str(), msg.size(), 0);
|
send(fd, msg.c_str(), msg.size(), 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user