This commit is contained in:
2024-01-24 00:23:33 +01:00
parent a997c7413f
commit 1cf52ef8b0
6 changed files with 65 additions and 22 deletions

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 10:35:52 by maldavid #+# #+# */
/* Updated: 2024/01/23 12:38:15 by maldavid ### ########.fr */
/* Updated: 2024/01/24 00:07:56 by vvaas ### ########.fr */
/* */
/******************************************************************************/
@@ -18,11 +18,12 @@
namespace irc
{
Client::Client(int fd, sockaddr_in sock, int id) : _s_data(sock), _fd(fd), _id(id) {}
Client::Client(int fd, sockaddr_in sock, int id) : _s_data(sock), _fd(fd), _id(id), _logged(false) {}
void Client::sendCode(const std::string& code, const std::string& msg)
{
const std::string command = code + " :" + msg;
logs::report(log_message, "C<-%s", command.c_str());
if(send(_fd, command.c_str(), command.size(), 0) != static_cast<ssize_t>(command.length()))
logs::report(log_error, "server failed to send a code to '%s' (:sadge:)", _username.c_str());
}
@@ -30,6 +31,7 @@ namespace irc
void Client::sendMsg(const std::string& sender, const std::string& cmd, const std::string& trailing)
{
const std::string out = ':' + sender + ' ' + cmd + " :" + trailing + "\r\n";
logs::report(log_message,"<- S %s", out.c_str());
if(send(_fd, out.c_str(), out.length(), 0) != static_cast<ssize_t>(out.length()))
logs::report(log_error, "server failed to send a message from '%s' to '%s' (:sadge:)", sender.c_str(), _username.c_str());
}