ft_irc/srcs/commands/other/ping_pong.cpp
2023-03-10 22:31:37 +01:00

69 lines
2.4 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ping_pong.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/13 00:16:27 by apommier #+# #+# */
/* Updated: 2023/03/10 22:16:50 by apommier ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../../includes/ft_irc.hpp"
// void ft_putstr_fd(int fd, std::string str)
// {
// write(fd, str.c_str(), str.size());
// write(fd, "\n", 1);
// }
void PONG(std::string buffer, fdList &allFds, int userNbr)
{
(void)buffer;
(void)allFds;
(void)userNbr;
std::string msg;
std::vector<std::string> splitBuff;
split(buffer, ' ', splitBuff);
msg = ":irc.local PONG irc.local :irc.local\r\n";
// ":irc.local PONG irc.local :irc.local"
send(allFds.userData[userNbr].fd, msg.c_str(), msg.size(), 0);
// if (splitBuff.size() < 2)
// {
// cmd_error(allFds, allFds.userData[userNbr].fd, "431 " + allFds.userData[userNbr].nickname + " NICK :No nickname given\n");
// //write(allFds.userData[user].fd, "ERR_NEEDMOREPARAMS", 18);
// return ;
// }
return ;
}
void PING(std::string buffer, fdList &allFds, int userNbr)
{
(void)buffer;
(void)allFds;
(void)userNbr;
std::string msg;
std::vector<std::string> splitBuff;
split(buffer, ' ', splitBuff);
msg = ":irc.local PONG irc.local :" + splitBuff[1] + "\r\n";
//msg = "PONG irc.local " + splitBuff[1];
send(allFds.userData[userNbr].fd, msg.c_str(), msg.size(), 0);
//std::cout << "pong send\n";
//std::cout << "/r = " << (int)'\r' << "\n";
//std::cout << "/n = " << (int)'\n' << "\n";
//std::cout << "msg=" << msg << "\n";
// if (splitBuff.size() < 2)
// {
// cmd_error(allFds, allFds.userData[userNbr].fd, "431 " + allFds.userData[userNbr].nickname + " NICK :No nickname given\n");
// //write(allFds.userData[user].fd, "ERR_NEEDMOREPARAMS", 18);
// return ;
// }
return ;
}