summaryrefslogtreecommitdiff
path: root/src/session.hpp
blob: 8e0859cc2066576f2c4017e813b14bee65a9fe0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
};