xbot/ping_thread.cpp

20 lines
463 B
C++
Raw Permalink Normal View History

2023-11-25 09:22:55 -08:00
#include "ping_thread.hpp"
2023-11-27 19:09:45 -08:00
#include "connection.hpp"
2023-11-25 09:22:55 -08:00
#include "irc_parse_thread.hpp"
2023-11-27 19:09:45 -08:00
#include "ircmsg.hpp"
2023-11-25 09:22:55 -08:00
#include "write_irc.hpp"
2023-11-27 14:12:20 -08:00
auto PingThread::start(Connection& connection) -> void
2023-11-25 09:22:55 -08:00
{
2023-11-26 15:40:40 -08:00
connection.add_listener<IrcMsgEvent>([&connection](IrcMsgEvent& event)
2023-11-25 09:22:55 -08:00
{
2023-11-25 20:09:20 -08:00
auto& irc = event.irc;
2023-11-26 15:08:55 -08:00
if (IrcCommand::PING == event.command)
2023-11-25 09:22:55 -08:00
{
2023-11-26 15:40:40 -08:00
send_pong(connection, irc.args[0]);
2023-11-25 20:09:20 -08:00
event.handled_ = true;
2023-11-25 09:22:55 -08:00
}
2023-11-25 20:09:20 -08:00
});
2023-11-25 09:22:55 -08:00
}