forked from codewhite7777/ft_irc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClient.hpp
104 lines (89 loc) · 3.23 KB
/
Client.hpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Client.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mgo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/12 11:19:55 by mgo #+# #+# */
/* Updated: 2022/10/12 11:19:57 by mgo ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CLIENT_HPP
# define CLIENT_HPP
# include <string>
typedef int SOCKET;
class Server;
class Command;
class Protocol;
class Channel;
class Client
{
public:
Client(SOCKET s, std::string host_name, Server* sv);
~Client(void);
SOCKET& getSocket(void);
void appendToRecvBuf(unsigned char* buf);
size_t getRecvBufLength(void);
void appendToSendBuf(const std::string& str);
const char* getSendBufCStr(void);
size_t getSendBufLength(void);
void eraseSendBufSize(int size);
void processMessageInRecvBuf();
const std::string& getCommand(void) const;
const std::string& getParam(void) const;
bool isWelcomed(void) const;
bool getDisconnectFlag(void) const;
void setDisconnectFlag(bool flag);
void setPassFlag(bool flag);
bool getPassFlag(void) const;
void setNickname(std::string nickname);
const std::string& getNickname(void) const;
void setNickFlagOn(void);
bool getNickFlag(void) const;
void setUsername(std::string username);
void setHostname(std::string hostname);
void setRealname(std::string username);
const std::string& getUsername(void) const;
const std::string& getHostname(void) const;
const std::string& getRealname(void) const;
const std::string getUserRealHostNamesInfo(void) const;
void setUserFlagOn(void);
bool getUserFlag(void) const;
std::string getNamesPrefix(void) const;
void setSvOperFlagOn(void);
bool isSvOper(void) const;
void promptRecvedMsg(void);
void promptSendedMsg(void);
private:
void marshalMessageToCmdAndParam(void);
std::string extractFirstMsg(std::string& recv_buf);
void processProtocol(void);
void processAuthToWelcome(void);
bool isPassed(void) const;
void processCommand(void);
void clearCommandAndParam(void);
std::string& getRecvBuf(void);
std::string& getSendBuf(void);
void promptCommandAndParam(void);
SOCKET sock_des_;
std::string send_buf_;
std::string recv_buf_;
std::string command_;
std::string param_;
bool pass_flag_;
bool nick_flag_;
bool user_flag_;
std::string nickname_;
std::string username_;
std::string hostname_;
std::string realname_;
bool disconnect_flag_;
bool sv_oper_flag_;
bool passed_;
bool welcomed_;
Server* sv_;
Command* cmd_;
Protocol* proto_;
};
#endif