diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-03-04 23:29:39 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-03-04 23:29:39 +0800 |
| commit | 09d899230c3d31bd405cc3407c6c372ab9091e98 (patch) | |
| tree | c6a34436ec3d1a3e99dde3b97dea820d85dc37b9 /src/session.hpp | |
| parent | bf95e496e2f03fcffb9c6043307f13c99a18d8d0 (diff) | |
refactor!: python -> c++
Diffstat (limited to 'src/session.hpp')
| -rw-r--r-- | src/session.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/session.hpp b/src/session.hpp new file mode 100644 index 0000000..8e0859c --- /dev/null +++ b/src/session.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include "FileDescriptor.hpp" +#include <string> + +class CSession { + public: + struct SRecvData { + char data[1024] = {0}; + ssize_t dataSize = sizeof(data); + bool good = true; + }; + CSession(Hyprutils::OS::CFileDescriptor m_sockfd); + ~CSession(); + std::string getName() const; + bool isValid() const; + SRecvData read(); + SRecvData read(std::string &msg); + bool write(const std::string &msg) const; + void run(); + + private: + Hyprutils::OS::CFileDescriptor m_sockfd; + std::string m_name; + void recvManager(); + bool registerSession(); +void onConnect() const; +void onDisconnect() const; +void onErrno() const; +void onRecv(SRecvData &data) const; + friend class CSessionManager; +}; |
