xbot/registration_thread.hpp

52 lines
1.3 KiB
C++
Raw Permalink Normal View History

2023-11-25 09:22:55 -08:00
#pragma once
2023-11-27 19:09:45 -08:00
#include <eventpp/eventdispatcher.h>
2023-11-25 09:22:55 -08:00
#include "connection.hpp"
#include "irc_parse_thread.hpp"
2023-11-27 14:12:20 -08:00
#include <memory>
2023-11-25 20:09:20 -08:00
#include <string>
2023-11-27 14:12:20 -08:00
#include <unordered_map>
#include <unordered_set>
2023-11-25 09:22:55 -08:00
2023-11-27 14:12:20 -08:00
class RegistrationThread : public std::enable_shared_from_this<RegistrationThread>
{
Connection& connection_;
std::string password_;
std::string username_;
std::string realname_;
std::string nickname_;
std::unordered_map<std::string, std::string> caps;
std::unordered_set<std::string> outstanding;
Connection::Handle<ConnectEvent> connect_handle_;
Connection::Handle<IrcMsgEvent> message_handle_;
auto on_connect() -> void;
auto send_req() -> void;
auto on_msg_cap_ls(IrcMsg const& msg) -> void;
auto on_msg_cap_ack(IrcMsg const& msg) -> void;
auto listen_for_cap_ack() -> void;
auto listen_for_cap_ls() -> void;
public:
RegistrationThread(
Connection& connection_,
std::string password,
std::string username,
std::string realname,
std::string nickname
);
static auto start(
Connection& connection,
std::string password,
std::string username,
std::string realname,
std::string nickname
) -> std::shared_ptr<RegistrationThread>;
};