From 6f7b994684032060f0a2d7af82f4f3572293b8d6 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 12 Jun 2025 21:41:41 +0800 Subject: internal!: organized internal structure, using cmake now --- src/session.hpp | 88 --------------------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 src/session.hpp (limited to 'src/session.hpp') diff --git a/src/session.hpp b/src/session.hpp deleted file mode 100644 index 2ca274e..0000000 --- a/src/session.hpp +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once - -#include "FileDescriptor.hpp" -#include "chatManager.hpp" -#include "format.hpp" -#include -#include -#include -#include -#include -#include -#include - -class CSession { - public: - CSession(); - ~CSession(); - - struct SRecvData { - std::string data; - const size_t size = 1024; - bool good = false; - - bool isEmpty() const; - void sanitize(); - - static constexpr char asciiEscape = 0x1B; //  - }; - - const std::string &getName() const; - const std::string &getIp() const; - bool isAdmin() const; - - std::unique_ptr read(); - std::unique_ptr read(const std::string &msg, bool bypassDeaf = false); - bool write(const std::string &msg); - template - bool write(std::format_string fmt, Args &&...args); - template - bool write(eFormatType type, std::format_string fmt, Args &&...args); - bool writeChat(const CChatManager::SMessage &msg); - - bool isMuted() const; - void setMuted(bool mute); - bool isDeaf() const; - void setDeaf(bool deaf); - - void run(); - - bool isValid(); - - private: - constexpr static char m_adminIps[1][INET_ADDRSTRLEN] = {"127.0.0.1"}; - - enum eEventType : std::uint8_t { - READ, - WRITE - }; - - std::weak_ptr self; - std::shared_ptr m_sockfd; - sockaddr_in m_addr; - socklen_t m_addrLen = sizeof(m_addr); - std::string m_name; - std::string m_ip; - int m_port; - bool m_isAdmin = false; - - std::optional m_szReading = std::nullopt; - bool m_bMuted = false; - bool m_bDeaf = true; // init as true as we don't want anything during registerSession - - void recvLoop(); - bool registerSession(); - -#ifdef DEBUG - void onConnect(); - void onDisconnect(); -#endif - void onErrno(eEventType); -#ifdef DEBUG - void onRecv(const SRecvData &data); - void onSend(const std::string &msg); -#endif - - friend class CSessionManager; - friend void registerCommands(); -}; -- cgit v1.2.3