xbot/ping_thread.cpp

26 lines
677 B
C++

#include "ping_thread.hpp"
#include "irc_parse_thread.hpp"
#include "write_irc.hpp"
PingThread::PingThread(Connection * connection) noexcept : connection_{connection} {}
auto PingThread::priority() const -> priority_type
{
return 1;
}
auto PingThread::on_event(Event const& event) -> std::pair<ThreadOutcome, EventOutcome>
{
if (auto const irc_event = dynamic_cast<IrcMsgEvent const*>(&event))
{
auto& irc = irc_event->irc;
if ("PING" == irc.command && 1 == irc.args.size())
{
write_irc(*connection_, "PONG", irc.args[0]);
return {ThreadOutcome::Continue, EventOutcome::Consume};
}
}
return {};
}