-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.cpp
More file actions
128 lines (103 loc) · 1.95 KB
/
Client.cpp
File metadata and controls
128 lines (103 loc) · 1.95 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "Client.hpp"
Client::Client()
: _fd(-1), _registered(false), _authenticated(false)
{
// std::cout << "Client Default Constructor Called" << std::endl;
}
Client::Client(int fd)
: _fd(fd), _registered(false), _authenticated(false) // Initialize other members if necessary
{
// std::cout << "Client Constructor with fd Called" << std::endl;
}
Client::Client(int fd, const std::string& address)
: _fd(fd), _ipAddress(address), _registered(false) {}
Client::~Client()
{
// std::cout << "Client Destructor Called" << std::endl;
}
void Client::joinChannel(const std::string &channelName)
{
_joinedChannels.insert(channelName);
}
// Getters
int Client::getFd() const
{
return _fd;
}
std::string Client::getNickname() const
{
if(_nickname.empty())
return "*";
return _nickname;
}
std::string Client::getUsername() const
{
return _username;
}
std::string Client::getRealname() const
{
return _realname;
}
std::string Client::getPassword() const
{
return _password;
}
bool Client::isRegistered() const
{
return _registered;
}
// Setters
void Client::setFd(int fd)
{
_fd = fd;
}
void Client::setIpAddress(const std::string& ip)
{
_ipAddress = ip;
}
void Client::setNickname(const std::string nickname)
{
_nickname = nickname;
}
void Client::setUserName(const std::string username)
{
_username = username;
}
void Client::setRealName(const std::string realname)
{
_realname = realname;
}
void Client::setRegistered(bool registered)
{
_registered = registered;
}
void Client::setPassword(const std::string password)
{
_password = password;
}
bool Client::authenticate()
{
if(_nickname.empty() || _username.empty() || _password.empty())
return false;
return true;
}
void Client::setBuffer(char *buf)
{
_buffer += buf;
}
void Client::delete_buffer()
{
_buffer.clear();
}
std::string Client::getBuffer() const
{
return _buffer;
}
void Client::setAuth(bool auth)
{
_authenticated = auth;
}
bool Client::isAuth() const
{
return _authenticated;
}