2023-11-25 09:22:55 -08:00
|
|
|
#include "ping_thread.hpp"
|
|
|
|
|
|
|
|
#include "irc_parse_thread.hpp"
|
|
|
|
#include "write_irc.hpp"
|
|
|
|
|
2023-11-25 20:09:20 -08:00
|
|
|
auto ping_thread(Connection * connection) -> void
|
2023-11-25 09:22:55 -08:00
|
|
|
{
|
2023-11-25 20:09:20 -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-25 09:22:55 -08:00
|
|
|
if ("PING" == irc.command && 1 == irc.args.size())
|
|
|
|
{
|
2023-11-25 20:09:20 -08:00
|
|
|
write_irc(*connection, "PONG", irc.args[0]);
|
|
|
|
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
|
|
|
}
|